Skip to content Skip to sidebar Skip to footer

How To Know When Multiple Asynchronous Calls To Complete Then Call Another Command?

I am getting trouble when making multiple asynchronous call in javascript and ajax. Everything look like start in multiple thread at the same time and output depend on the time it

Solution 1:

jQuery introduces the deferred object which allows you to execute a series of methods followed by some sort of done callback.

http://api.jquery.com/category/deferred-object/

http://api.jquery.com/deferred.done/

http://api.jquery.com/deferred.fail/

async.js is another library for executing a series of asynchronous commands followed by a single callback.

async.parallel([
    function(){ ... },
    function(){ ... }
], callback);

async.series([
    function(){ ... },
    function(){ ... }
]);

Post a Comment for "How To Know When Multiple Asynchronous Calls To Complete Then Call Another Command?"