views:

175

answers:

3

I've rewritten my family web site using Javascript (JQuery) making ajax calls to php on the back end. It's your standard "bunch of image thumbnails and one main image, and when you click on a thumbnail image the main image changes" kind of thing. Everything is working as expected when using Firefox, but on IE, when I click on a thumbnail, the main image changes to the one I clicked and then immediately changes back to the first one. I have tried MS Script Debugger to no avail; I set a breakpoint in the javascript code that starts the ajax call, and when I click the thumbnail the breakpoint fires. Then I hit F5 and it continues but does not fire again. If I use Wireshark to watch the actual TCP packets over the network, I can see that we are definitely sending more than one request to the server. I cannot figure out where the second query (the one to revert back to the original image) comes from.

Any suggestions? One example of what I'm talking about is here.

+1  A: 
splattne
A: 

IE is a piece of work isn't it? Have you tried something like this?

var inProcess = 0;

function eventHandler() {

if (inProcess == 0) {

  inProcess = 1;

  // do stuff

  setTimeout('inProcess = 0', 5000);

}

}

Cute kid, by the way.

Glenn
+3  A: 

Debugging through your site here's what it looks is happening:

After the first image is pocessed, the resize event is being thrown, so this code gets called:

$(window).bind("resize", function(){ ResizeWindow( 'nicholas-1' );});;});

which as you know reloads your gallery. Now I can;t tell you why this is occuring but this is where the trouble starts.

For future reference to debug this I used VS2008 to attach to IE. I then put a break in $ajax() at:

 // Send the data
 try {
  xhr.send(s.data);
 } catch(e) {
  jQuery.handleError(s, xhr, null, e);
 }

Then I simply hit F5 which is run for the first two ajax calls, then I open up the call stack window when I found the rogue ajax call and walked the call stack back up to the function I pasted earlier.

Good luck.

JoshBerke
I'll have to debug a little more, but disabling the resize handler fixed the problem. Thanks!
Graeme Perrow
Your welcome! neat site by the way;-)
JoshBerke