Briefly, I have a page that does the following:
1) User types the URL of a website into a text box and hits enter.
2) AJAX request to PHP script which tries to open the URL using cURL to see if the URL is broken or not.
3) Response sent to browser, picked up by AJAX and message displayed on screen.
The cURL timeout is set to 10 seconds - I think that's a reasonable time to expect a response from a remote server.
I've tested this code in FF, Opera, Chrome, Iceweasle and Safari and it works fine in all those.
But in IE 9 ... it doesn't work! (Surprise!!!! Good old IE, always screwing things up).
So I dug into the code a little and the problem surfaces here:
Sure enough, in IE (and only in IE), I get an alert box which shows the ajax status to be 12002.
//ajax is an instance of an ActiveXObject.
if (ajax.readyState == 4)
if (ajax.status == 200)
if (userfunc != 0)
alert("An error has occured making the request: " + ajax.status);
12002 turns out to be ERROR_INTERNET_TIMEOUT (See here: http://forums.codeguru.com/showthrea...72#post1623372)
So, I had another rummage in Google, and I found this: http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
In that microsoft link, it clearly states, "With the timeout property, Web developers can specify the length of time in milliseconds for the host to wait for a response before timing out the connection". It actually says that on Microsoft's own website, so it must be true ... but apparently not ... read on ...
I have implemented the timeout precisely as described in that document, except I have given it a value of 20000 milliseconds.
And the result is .... (drumroll) ... it has no effect whatsoever. The request times out after 10 seconds as before.
I can implement an AJAX poll once every 5 seconds, but this seems complete overkill for a problem which Microsoft themselves say is easy to fix with a single line of code!!! Only it doesn't work on my browser ...