Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9128237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:28:05+00:00 2026-06-17T07:28:05+00:00

Please take a look at the following code, do you think which log will

  • 0

Please take a look at the following code, do you think which log will be printed first?
In Chrome & IE, “sync ajax call: success” is showed first which is expected,
BUT in FF(tested in FF 3.6 & FF 17.0), “async ajax call: success” is showed first instead,
which means although we make the second one as a sychronous call, but when its onreadystatechange was triggered, the handler of asychronous(first) ajax call was executed earliar than that of sychronous(second) ajax call, does it make sense?
Isn’t it 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) {
    }
})
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:28:07+00:00Added an answer on June 17, 2026 at 7:28 am

    to implement something “correctly” , there must be some specification.

    Inside the specification I haven’t found any reference to the fact that all scripts should stop executing as long as the synchronous request isn’t finished(note that the async-XHR is already running when the sync-XHR starts).

    But I found this:

    1. Each XMLHttpRequest object has its own task source. Namely, the XMLHttpRequest task source.
      —both requests represent a single task-source—

    2. When a user agent is to queue a task, it must add the given task to one of the task queues of the relevant event loop. […] tasks from different task sources may be placed in different task queues.
      —both tasks may be added to the same task-queue, but must not—

    3. An event loop must continually run through the following steps for as long as it exists:
      1.Run the oldest task on one of the event loop’s task queues, if any, […]. The user agent may pick any task queue.

      —he picks now the task-queue where he puts on the synchronous request

    When I not misunderstood this, and my logic is not wrong, this could be going on:

    Firefox puts both XHR on the same queue, IE and chrome put them onto different task-queues.

    All browsers run now the task-queue where they placed the synchronous XHR.

    • In IE and chrome the synchronous XHR is the oldest task in his queue and runs
    • In FF the asynchronous XHR is the oldest in his queue and runs

    Both implementations seem to be correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please take a look at the following code: http://jsfiddle.net/htdTg/2/ In the first link there
Firstly please take a look at the following code, which consists of 2 translation
Please take a look at the following autocomplete code. $(document).ready(function(){ $(#the_input).autocomplete(/autocomplete.php, { //some options
Please take a look at following code: #include <stdio.h> #include <iostream> using namespace std;
Can you please take a look at following code and let me know why
Please take a look at the following code: Public Sub Method(Of TEntity As EntityObject)(ByVal
Please take a look at the following code: Try Dim Reader As New System.IO.StreamReader(PositionsFileName)
Would someone please take a look at the following code fragments (all from one
Please take a look at following code: public class SomeEntity { public int Id
please take a look at the following code snippet: #include <stdio.h> int main ()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.