An assumption on the reason :
If the host in the URL does not exist, no request is actually made. While in IE only the request is asynchronous, in other browsers the host lookup is also asynchronous.
Question
I have a dumb simple ajax call to a nonexistent url with an error callback:
$.ajax("non-nonexistent-url", {
error: function () {
alert("FOO");
}
});
alert("BAR");
When I run it in Chrome, I get "BAR" then "FOO" alerts, which is the behavior I expect - ajax call is asynchronous.
In IE, however, I get "FOO" then "BAR", which looks like synchronous call, but why? It should be async by default, right?
I hoped it's guaranteed that $.ajax
returns before any callbacks are executed...
Solution
An assumption on the reason :
If the host in the URL does not exist, no request is actually made. While in IE only the request is asynchronous, in other browsers the host lookup is also asynchronous.