Is Ajax implemented correctly in Firefox? Synchronous problem

Please take a look at the following code, what do you think will be the first magazine to be printed?
In Chrome and IE, "sync ajax call: success" first appears, which is expected
BUT in FF (tested in FF 3.6 and FF 17.0) instead shows "an asynchronous ajax call: success", which means that we make the second as a synchronous call, but when its onreadystatechange is started, the asynchronous (first) ajax call handler was made earlier than the synchronous (second) ajax call, does it make sense?
Isn't that a firefox bug?

// first ajax call, Note: this is asynchronous. $.ajax({ url: "/rest/someUrl", async : true, dataType : "json", contentType: "application/json", success : function(data) { console.log("async ajax call: success"); }, error : function(data) { } }) // second ajax call, Note: this is synchronous. $.ajax({ url: "/rest/someUrl", async : false, dataType : "json", contentType: "application/json", success : function(data) { console.log("sync ajax call: success"); }, error : function(data) { } }) 
+4
source share
1 answer

to implement something "correctly", there must be some kind of specification.

Inside the specification, I did not find a reference to the fact that all scripts should stop executing before the synchronous request is complete (note that async-XHR is already running when sync-XHR starts).

But I found this:

When I do not understand this wrong, and my logic is not wrong, this can happen:

Firefox puts both XHRs in the same queue, IE and Chrome put them in different task queues.

All browsers now start the task queue, where they host the synchronous XHR.

  • In IE and Chrome, synchronous XHR is the oldest task in its lineup and runs
  • In FF, asynchronous XHR is the oldest in its lineup and runs

Both implementations seem correct.

+5
source

All Articles