deferred.always() fires too early
var xhr1 = $.ajax({ url:'/echo/json/', data:{ delay: 3 } }),
xhr2 = $.ajax({ url:'/echo/json/something/invalid', data:{ delay: 3 } });
xhr1.always(function(){
console.log('xhr1 always');
});
xhr2.always(function(){
console.log('xhr2 always');
});
$.when.apply($, [xhr1, xhr2]).always(function(){
console.log('xhr1 & xhr2 always');
});
Result (console):
xhr2 always
xhr1 & xhr2 always
xhr1 always
Why doesn't deferred.always() wait for both ajax calls to be completed? Is
there any defered callback which can be used when all requests are done,
regardless of their status?
http://jsfiddle.net/W9A3f/
No comments:
Post a Comment