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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:53:13+00:00 2026-06-14T22:53:13+00:00

I have mutiple processes that need to be called in series (I am using

  • 0

I have mutiple processes that need to be called in series (I am using synchronous AJAX calls). I would like to display status of a long running process after its completion and then proceed to the next one. Here is a sample code I have written.

    var counter = 0;
function runProcess(input, output) {
    doWork();
    doWork();
    doWork();
};
function doWork() {
    counter++;
    document.getElementById('<%=this.progressMonitor.ClientID%>').innerHTML += "Running " + counter;

    // some lengthy calculations
    for (var i = 0; i < 1000000; i++) {
        var foo = Math.random();
    }
    setTimeout(updateStatus, 1000);
};
function updateStatus() {
    document.getElementById('<%=this.progressMonitor.ClientID%>').innerHTML += "Done " + counter;
}

When I run this, I get the following response:

Running 1Running 2Running 3Done 3Done 3Done 3

I would like to get

Running 1Done 1Running 2Done 2Running 3Done 3

If I insert a alert() statement in updateStatus function, then I get the response/execution order I want. Is the browser creating 3 threads for 3 function calls and executing them asynchronously?

How can I run this in series? Is setTimeout implemented correctly? Thanks for your help in advance.

  • 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-14T22:53:14+00:00Added an answer on June 14, 2026 at 10:53 pm

    It sounds like you want to queue up AJAX calls. jQuery provides a good queue function, so you can make sure a series of functions gets called one after the other. Mootools and other frameworks provide similar functionality.

    Here is the code from my fiddle that shows how to do it.

    var queueElement = $("#output");
    var counter = 0;
    
    function doWork(next) {
        queueElement.append("Starting " + counter + "<br/>");
        counter++;
        $.ajax('/echo/json/').always(function() {
            queueElement.append("Ending " + counter + "<br/>");
            next();
        });
    }
    
    queueElement.queue('workQueue', doWork);
    queueElement.queue('workQueue', doWork);
    queueElement.queue('workQueue', doWork);
    queueElement.dequeue('workQueue'); // start the work queue
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file and searching mutiple value i.e I need to search {Name,Class}
I'm writing a bash script that spawns a number of background processes. I'd like
I have a program that I need to use signals and handlers with. I
Assume that I have a set of objects that need to be analyzed in
Alright, I'm making a website using PHP/HTML, and I have some backend AJAX to
The problem : I have multiple parallel processes that handle flat file records .
We have some data structures that we are sharing across processes on Windows. (Via
I have a method that I call to make web service requests using GET.
I am to process single PDFs that have each been created by 'merging' multiple
If have I have multiple processes accessing a registry value thousands of times per

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.