Reputation: 43853
In my page I am using SharePoint 2010 client object model to call asynchronous functions (ajax calls). On page load, I make lots of ajax calls to load data. But I would like to know if there is a way so that a function can get called once all the ajax calls are done. Is there someway to do this? Thanks
Upvotes: 0
Views: 1770
Reputation: 50493
A jquery solution, use $.active
to see how many active requests there are.
So...
var ajaxCheckInterval = setInterval(checkAjaxState, 10);
function checkAjaxState(){
if($.active == 0){
clearInterval(ajaxCheckInterval);
// do work
}
}
Possibly something like this:
var ajaxCheckInterval = setInterval(checkAjaxState, 10);
function checkAjaxState(){
if(document.readyState == 'complete'){
clearInterval(ajaxCheckInterval);
// do work
}
}
Upvotes: -1