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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:08:47+00:00 2026-06-14T23:08:47+00:00

i need some help on some code that i m writting.. my code fires

  • 0

i need some help on some code that i m writting..
my code fires three asychronous requests and updates some content on my page.
i want these requests to be fired every X seconds..
i have seen several questions like this, how to schedule ajax calls every N seconds? regarding setTimeout or setInterval, but the issue is that i need each request to be fired every x seconds..while the only i can think of that setInterval / settimeout wouldn’t count seperate time for each call, but just one time..
for instance

if i have xhr1 at 00.00.01 xhr2 at 00.00.02 and xhr3 at 00.00.03

what aproach would it be best for the next call to be after 20seconds for each?

xhr1 00.00.21 xhr2 00.00.22 xhr3 00.00.23

xhr1 00.00.41 xhr2 00.00.32 xhr3 00.00.33

also my current code is writen in that way that every xhr is fired after response of previous has been received using a callback function

function request(url, callback){
....
asychronous request
....
callback(responseText);
}

request(url1, function(){
some code
}
request(url2, function(){
some code
}
request(url3, function(){
some code
}

if another approach is suggested as well for the three calls, i would like to know..

  • 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-14T23:08:48+00:00Added an answer on June 14, 2026 at 11:08 pm

    As this is an intricate scenario, I’d recommend that you look into promises. It’s not an easy concept, but it’ll allow you to keep a clear separation of concerns between your chaining needs and your callbacks.

    Without promises, you would need to include the next xhr call in your callback.

    Promises are included in JavaScript libraries like jQuery or Dojo.

    A simpler scenario would be to forget about chaining the requests:

    function allRequests(){
    request(url1, function(){some code});
    // url2 one second later
    setTimeout(function(){request(url2, function(){some code});},1000);
    // url3 one more second later
    setTimeout(function(){request(url3, function(){some code});},2000);
    }
    // run the 3 requests every 20 seconds
    setInterval(allRequests(),20000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am not that skilled at Excel/VBA and need some help. The code below (in
Hey guys! I need some help writing a code that creates an array in
I need some help in terms of profiling existing code in terms of execution
I need some help understanding this bit of code pre { white-space: pre; white-space:
I need some help with some PHP and MySQL code. At the moment I
Hey all i am in need of some help getting my code working correctly
Need some regular expressions help. So far I have my code working to allow
I need your help with some sample code for a situation I could not
I need your help in JAVA (with some sample code if possible) regarding to
I got some code off the Internet and now I just need help 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.