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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:13:32+00:00 2026-06-07T03:13:32+00:00

So here’s the situation: I have a recursive, asynchronous AJAX call which is pulling

  • 0

So here’s the situation:

I have a recursive, asynchronous AJAX call which is pulling data from the server. This recursive call happens only once when the user logs in.
I have another page which requires AJAX calls in order to navigate (basically a lazy-loaded tree). While the first AJAX call is happening, these other calls are taking a while to go through, and since the first could make as many as 2,000 requests, this delay can sometimes be fairly long.

Basically what I would like to achieve is to “pause” the recursive call when the other call is made. Pseudo code:

function recursiveAjax(){    
    $.ajax( {
        async : true,
        url : 'someurl',
        dataType : 'json',
        beforeSend : function(xhr) {
            // do stuff
        },
        error : function(xhr, ajaxOptions, thrownError) {
            // handle errors
        },
        success : function(data) {
            //conditions
            recursiveAjax();
        }
    });
}

function navigationAjax(){    
    $.ajax( {
        async : true,
        url : 'someurl',
        dataType : 'json',
        beforeSend : function(xhr) {
            // pause recursiveAjax();
        },
        error : function(xhr, ajaxOptions, thrownError) {
            // handle errors
        },
        success : function(data) {
            //conditions
            // resume recursiveAjax();
        }
    });
}
  • 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-07T03:13:33+00:00Added an answer on June 7, 2026 at 3:13 am

    As you probably don’t want the two requests at the same time, let the recursive method do one or the other. Set a flag when you want the navigation call, and let the recursive method do that request the next iteration:

    var navigationCall = false;
    
    function recursiveAjax(){
      if (navigationCall) {
        navigationCall = false;
        $.ajax( {
          async : true,
          url : 'someurl',
          dataType : 'json',
          error : function(xhr, ajaxOptions, thrownError) {
            // handle errors
          },
          success : function(data) {
            //conditions
            recursiveAjax();
          }
        });
      } else {
        $.ajax( {
          async : true,
          url : 'someurl',
          dataType : 'json',
          beforeSend : function(xhr) {
            // do stuff
          },
          error : function(xhr, ajaxOptions, thrownError) {
            // handle errors
          },
          success : function(data) {
            //conditions
            recursiveAjax();
          }
        });
      }
    }
    
    function navigationAjax(){
      navigationCall = true;
    }
    

    Note: You might want to add a window.TimeOut call to do the recursion to throttle the streams of requests to the server. There is no point in calling the server more often than the human eye can see the changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my situation: I have a Data Template set up which contains a ToggleButton
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is what I am trying to achieve in PHP: I have this string:
Here I am trying to retrieve the response from the server and display it,
Here is the code in a function I'm trying to revise. This example works
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
Here's the basic setup: I have a thin bar at the top of a
Here is my problem : I have a post controller with the action create.
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();

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.