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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:11:03+00:00 2026-05-17T00:11:03+00:00

Here’s the code – this runs as soon as the document is loaded (inside

  • 0

Here’s the code – this runs as soon as the document is loaded (inside $(document).ready(function(){ ) Is there a way to code this so that the next ajax query will run after the current one is finished? I want to create more ajax calls on the page, but they will not execute until all the queued calls are completed. If each call would run after the other is executed, this will give new ajax calls a chance to get to the front of the next script insead of at the end of all 30. Any advice would be appreciated.

for (var x=0;x<=30;x++)
{
emailnumber = '<?php echo $storage->countMessages(); ?>'-x;
dataString='emailnumber='+emailnumber+'&url=<?php echo $url; ?>&email=<?php echo $email_address; ?>';

    $.ajax({

       type: "POST",

    url: "phpdocument.php",

    data: dataString,

    success: function(msg){

            $('#results').append(msg);

        }

    });


}

Edit: Should I be using the setTimeout function somewhere?

  • 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-17T00:11:04+00:00Added an answer on May 17, 2026 at 12:11 am

    Set async to false in the options for your ajax() call. But, know this: synchronous Ajax requests may lock the browser. This is because the Ajax request will halt further execution until complete. In other words, you won’t get out of the for loop until all the Ajax requests have completed.

    for (var x = 0; x <= 30; x++) {
        emailnumber = '<?php echo $storage->countMessages(); ?>' - x;
        dataString = 'emailnumber=' + emailnumber + '&url=<?php echo $url; ?>&email=<?php echo $email_address; ?>';
    
        $.ajax({
    
            type: "POST",
            async: false,
            url: "phpdocument.php",
    
            data: dataString,
    
            success: function(msg) {
    
                $('#results').append(msg);
    
            }
        });
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code in a function I'm trying to revise. This example works
here is code: <script type=text/javascript> function doit(){ $('table td').each(function () { if ($(this).text().trim() !=
Here is my jquery for dialog </script> <script type=text/javascript> $.ajaxSetup({ cache: false }); $(document).ready(function
Here is an example: I write html code inside of textarea, then I swap
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();
Here is my code (Say we have a single button on the page that
Here's a coding problem for those that like this kind of thing. Let's see
Here is the code: Function getData(ByVal id As String) Dim reader As SqlClient.SqlDataReader Dim
I know there's a lot of other questions out there that deal with this

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.