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();
}
});
}