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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:35:03+00:00 2026-06-12T18:35:03+00:00

I have a workflow on JS, which should run several set by setTimeout functions

  • 0

I have a workflow on JS, which should run several set by setTimeout functions one by one. How this could be done with JS/jQuery, preferably in some easy and beautiful way?

It looks like this

function recursiveOne(arg1){
  if (allRight) return;

  doSomething();
  andAnotherOne();
  setTimeout(function(){recursiveOne(arg1)}, 3000);
}

function coreFunction(){
  recursiveOne(arg1);
  recursiveTwo(arg2);
  recursiveThree(arg3);
}

where recursiveTwo should start only when recursiveOne already done its last iteration.

The bad part is all functions work through setTimeout because I need to wait reaction from backend, and couldn’t receive it directly – only by HTML source.

Possible solutions, that I could see:

  • next function callback passed right in the previous function. Not too cool.
  • jQuery deffered object, which isn’t so beatiful too, but a bit better. The downside is I still should rise additional deffered request in each function I want to use this way.
  • 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-12T18:35:04+00:00Added an answer on June 12, 2026 at 6:35 pm

    You have to use a callback or invoke coreFunction directly. Below you can find a way to do it using array of functions.

    function recursiveOne(arg1){
       if(arg1 < 5){
          arg1++;
          setTimeout(function(){recursiveOne(arg1);}, 500);
       }else{
          console.log("func1 complete");
          coreFunction();
       }
    }
    
    function recursiveTwo(arg1){
       if(arg1 < 10){
          arg1++;
          setTimeout(function(){recursiveTwo(arg1);}, 500);
       }else{
          console.log("func2 complete");
          coreFunction();
       }
    }
    
    function recursiveThree(arg1){
        if(arg1 < 20){
          arg1++;
          setTimeout(function(){recursiveThree(arg1);}, 500);
       }else{
          console.log("func3 complete");
          coreFunction();
       }
    } 
    
    var funcSet = [recursiveOne, recursiveTwo, recursiveThree];
    var funcArgs = [[1], [5], [10]];
    
    function coreFunction(){
       if(funcSet.length){
           var func = funcSet.shift();
           func.apply(window, funcArgs.shift())
       }
    }
    coreFunction();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a one main Workflow which calls several activities asynchronously. Some of the
My application has several independent top-level windows, which all have completely different functions/workflows. I
Not a duplicate of this I have a pretty simple CRM workflow, which basicly
I have a SharePoint workflow which is running whenever the item changes . The
I have two workflow foundation (.NET 3.5 SP 1) application which compiles fine. It
I have an .NET 4.0 ASP.NET MVC application, which also hosts a Workflow Foundation
I have a workflow that I want to looks something like this: / Worker
I have a workflow of functions that eventually lead to a deployment of something.
AI have a WF 4 application which contains a sequence workflow that has a
I have two workflow services (state machines) that should cooperate and exchange information 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.