jquery deferred - wait until two calls complete
问题 I am looking for a way to do a callback after two ajax calls completes: $.when( call1(), call2() ).always(function() { // Here I want to be sure the two calls are done and to get their responses ); The catch is that one of the calls might fail. So, in my code the always will invoked without waiting to the other call. How can I wait for both calls to done (success or failure)? 回答1: Here is something that should do the trick: $.whenAllDone = function() { var deferreds = []; var result = $