0

This is a repost of the following SO question because I'm pretty convinced that this is a networking/server issue, and not something wrong with my code.

https://stackoverflow.com/questions/7842530/ie-9-30-second-ajax-post-requests

Here's the gist: When making an AJAX request in IE9 (and the 7/8 compatibility modes) via GET or POST the following events occur:

  1. Within 500ms, my server responds (Rails/Apache/Phusion Passenger)

  2. IE immediately sees the body of the response (as shown in the Developer Tools Network Tab)

  3. IE then waits until the timeout period has passed before it shows the headers (again in the Dev Tools) and notifies my Javascript.

As stated in the SO question, it looks like my server (or perhaps the networking layer in Windows 7) isn't closing the request until the timeout period has passed.

It works perfectly in all other browsers that I have tested. Does anyone have any idea why this might be happening?

Topher Fangio
  • 279
  • 3
  • 13

1 Answers1

0

Okay, so after much screwing around, I found out that sending an AJAX GET request a few hundred milliseconds after the POST seems to fix the issue. Not sure why, but it seems to close the previous connection first and let it finish.

So, my solution is as follows:

didSend: function(request, response) {
  if (SC.browser.msie && request.get('type') === "POST") {
    setTimeout(function() {
      Core360.Request.getUrl('/test_server').send();
    }, 500);
  }
}

And everything appears to work. I would still love to find out the actual problem, but seeing as the XMLHttpRequest object is waiting to call readystatechanged for some stupid reason...

Topher Fangio
  • 279
  • 3
  • 13