Last active
December 27, 2015 05:49
-
-
Save horiajurcut/7277536 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extending jQuery.when | |
if (jQuery.when.all === undefined) { | |
jQuery.when.all = function(deferreds) { | |
var deferred = new jQuery.Deferred(); | |
$.when.apply(jQuery, deferreds).then( | |
function() { | |
deferred.resolve(Array.prototype.slice.call(arguments)); | |
}, | |
function() { | |
deferred.fail(Array.prototype.slice.call(arguments)); | |
} | |
); | |
return deferred; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happens if one or more requests fail? Do you get a fail for those that failed and resolve callbacks when the successful ones complete? I guess I'm asking if you get the complete picture. I have a situation where I need to make multiple requests but I need to know if any fail and I also need to know when ALL requests have completed (either succeeded or failed). Thanks