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 623409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:05:23+00:00 2026-05-13T19:05:23+00:00

I need to be able to control the order of items being processed in

  • 0

I need to be able to control the order of items being processed in the $(document).ready event.
These are multiple controls, loaded from multiple files, all asking to be called in the ready event. They all start an async call to the server (AJAX). Only after they are all done, I need to do some extra work.

What would be the elegant solution for this?

  • 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-13T19:05:24+00:00Added an answer on May 13, 2026 at 7:05 pm

    Asynchronous requests fire in order, but will return in whatever order they complete in first. So there is not a sure fire way to force them to end at the same time, however, you can build rules to only run code after certain groups have returned.

    For instance, define a callback function with a set of rules, and pass it to each success callback for all of your ajax requests.

    var completedObject = {};
    
    function groupSuccessCallback() {
      // Test for any combination of requirements
      if ( completedObject.ajax1 && completedObject.ajax2 ) {
        ... // Do something that only requires 1 and 2
      }
      if ( completedObject.ajax1 && completedObject.ajax2 && completedObject.ajax3) { 
        ... // Do something that requires all 3 being done
            // your data is available at completedObject.ajax#
      }
    
      // Or test for _all_ entries for a dynamic count
      var allComplete = true;
      for(var i in completedObject) {
         if ( completedObject.hasOwnProperty(i) && !completedObject[i] ) {
           allComplete = false;
         }
      }
    
      // Do whatchya need.
      if (allComplete) { 
        alert("bb-b-bb-b-b-b-bbb... that's all folks!");
      }
    }
    

    Then set the flags inside of your success functions:

    // Ajax1
    completedObject['anything'] = false; // instantiate a dynamic entry in the object or use an array if you can't use names.
    $.ajax({
      ...,
      ...,
      success: function(data) {
        completedObject['anything'] = data || true;
        groupSuccessCallback();
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to to be able to control the alignment of text in the
I need to be able to determine when ContainsFocus changes on a Control (specifically
I'd like to output html controls using xslt, but I need to be able
i need to be able to make calls from an activity. so here is
I need to be able to create basic MS Project items (tasks, projects, resources,
I'm building a custom control, and I need it to be able to respond
So I have a user control within a window. I need to be able
In my webservice I need to be able to pull from 3 different tables
Users of the website need to able to store images in their area ,
Need to be able to pull Magento products into an external template. Need to

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.