All entries for Friday 13 February 2009
February 13, 2009
AJAX MultiCompleter
We recently needed to fire off a bunch of Prototype AJAX requests at once and be informed when they’re all finished. This simple class handles that for you. (Requires Prototype, of course.)
Download Ajax.MultiCompleter
Example
var c = new Ajax.MultiCompleter({
onComplete: function(){ alert("all jobs done") },
onSuccess: function(){ alert("all jobs were successful") },
});
// start off your requests
new Ajax.Request(url, { multiComplete : c });
new Ajax.Updater(url2, someDiv { multiComplete : c });
new Ajax.Request(url3, { multiComplete : c });
// tell it we're done adding
c.finishedAdding();