Forum Moderators: open

Message Too Old, No Replies

AJAX won't work in IE after page refresh?

Please help me figure this one out

         

FourDegreez

2:54 pm on Mar 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I open IE, load the page, click the button that triggers the call, and the AJAX code works. I hit refresh, click the button, the AJAX code hangs. If I close the browser and open it again, the code will work again..the first time only. Below is the code I'm using. By putting alerts throughout, I can see that it makes it past requester.send(null); but never gets inside the onreadystatechange function.

var requester = null;
try {
  requester = new XMLHttpRequest();
}
catch (error) {
  try {
    requester = new ActiveXObject("Microsoft.XMLHTTP");
  }
  catch (error) {
    requester = null;
  }
}

if (requester == null)
  return false;

requester.open("GET", rurl);
requester.send(null);

requester.onreadystatechange = function() {
  if (requester.readyState == 4) {
    if (requester.status == 200 ¦¦ requester.status == 304)
      alert("success");
    else
      alert("failure");
  }
  return true;
};

Someone, please help me out with this...

cmarshall

5:45 pm on Mar 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That all looks fine (for IE only, I'll SM you something that will work on many more browsers).

I'd look at your server-side code. Are you keying on sessions?