Bjorn
Bjorn

Reputation: 904

Ajax Calls in IE9 random failure

I've written an internet application that synchronizes every action by the user with the server. Therefore I have a lot of Ajax requests going (not at the same time though).

The application works great in Firefox and Chrome, but IE9 gives me a headache. I have totally random failures in IE9 with these post requests. Therefore, the problem is not reproducible by a clear action, however, it frequently occurs. If for example I perform exactly the same action ten times in a row, it can either succeed every time, or it can fail during one of these requests. I have profiled the network with IE Developer tools and it results in the following: http://screencast.com/t/VLcK5OKWQl

As you can see, the post request remains pending. In the detailed description of this call all info is blank, not even a request header.

I am totally lost with this problem. If anyone has any idea what this could be, please share with me, I will try anything!

By the way, I'm using jQuery (v1.7.1) $.post calls if this makes any difference. I've also included the following headers in the responding file:

header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Pragma: no-cache' );
header('Content-type: application/json; charset=utf-8');

Upvotes: 3

Views: 1499

Answers (2)

Bjorn
Bjorn

Reputation: 904

The following headers solved the problem for me:

ob_end_clean();
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP 1.1.
header('Pragma: no-cache'); // HTTP 1.0.
header('Expires: 0'); // Proxies.
header("Content-type: application/json; charset=utf-8");

Upvotes: 0

sje
sje

Reputation: 315

I've had the exact same problem and was able to solve it by not sending null as data on the request (just sending an integer instead etc.).

I also tried running the same request multiple times to debug what went wrong, and before changing the argument to "not null" I got random responses (either success, a null value or an error (status code 12031). After making the "not null argument" change, I've been able to run the same request 1000+ times without any failure.

That said, I'm not able to reproduce this anywhere else... so, it still doesn't make any sense :P

Upvotes: 1

Related Questions