Reputation: 1327
I use JQuery. There is a widget based application. There are multiple widgets on single page. Every widget contains N number of ajax request while loading the widgets.
How can i capture the event when result of all ajax request are received? Is there any way without timer?
Upvotes: 2
Views: 267
Reputation: 5550
The foolowing jquery method will be called on complete of every ajax request. If you know the number of ajax requests. so you can have a global variable and increment it on every call until it reaches the desired value and then trigger your desired event
var i=0;
$("body").ajaxComplete(function(event,request, settings) {
if(i==MAX_REQ){
alert("done all");
}
else {
i+=1;
}
});
Upvotes: 4