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

  • SEARCH
  • Home
  • 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 6594533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:49:27+00:00 2026-05-25T17:49:27+00:00

I have two nested ajax calls to server. In 1st ajax call, server returns

  • 0

I have two nested ajax calls to server.

In 1st ajax call, server returns me the XML which contain ordered list of objects, server order the list by date ascending order. Here, I do get objects in date’s ascending order.

In the second ajax call’s success function, I simply output the dates of objects, but my objects are suddenly surprisingly not in date’s ascending order, why?

My code looks like below (please don’t feel confused about my two ajax calls, I explained them after the code):

$.ajax({
    type : "GET",
    url : MY_URL_1,
    dataType : "xml",
    success : function(xml) {
            $(xml).find("DOCUMENT").each(function() {
               var eachXMLdata = $(this);
               var date = eachXMLdata.children("DATE").text();

               // I successfully get the date in ascending order
               console.log('date:'+date);



               $.ajax({
               type : "GET",
               url : MY_URL_2,
               dataType : "xml",
               success : function(xml) {
                        
                         var date = eachXMLdata.children("DATE").text();
             
                         //I have not change anything of eachXMLdata, 
                         //why the order of the dates get messed up here
                         console.log('date:'+date);


                    }//end of 2nd ajax success function
                });// end of 2nd ajax call

            });//end of "each" function
        }//end of 1st ajax success function
     });//end of 1st ajax call

As you saw above, there are two nested ajax calls, that’s the second ajax call is inside first ajax call’s success function (and in the "each" function).

In the first ajax call, I console output the date of each object, which is correctly showing in ascending order.

The strange problem comes after I output the objects’ date again in the second ajax call’s success function, the dates are no longer in ascending order, why? I have not change anything of eachXMLdata, why two console outputs give me different order of the dates? and how to get rid of it?

  • 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-05-25T17:49:27+00:00Added an answer on May 25, 2026 at 5:49 pm

    I finally get rid of the problem by set “async: false” for the inner ajax call. This is the root cause.

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

Sidebar

Related Questions

I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two nested DropDownLists (the value selected in the 1st ddl will limit
I have a div which contains two nested divs, one that specifies a height
I have two repeater which are nested..Means there is one repeater and inside that
I have two inner divs which are nested inside a wrapper div. I want
I have two nested repeaters in my *.aspx page. <asp:Repeater runat=server id=rptMain> <ItemTemplate> <h1><%#DataBinder.Eval(Container.DataItem,
I have two nested loop in XSL like this, at this moment I use
I have a div with two nested divs inside, the (float:left) one is the
I have two masterpages. A main.Master and a search.Master. The search.Master is a nested
What I'm talking about here are nested classes. Essentially, I have two classes that

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.