$.when returns a $.when object for all simultaneous requests with multiple ajax.
If everything succeeds .done() is executed, and if any of the URLs fails .fail() is executed.
How to handle partial success states? (ie) if 5 URLs are passed to $.when , if 3 succeeds, we need to handle the success state and this will not work, we need to handle the failure state.
$.when($.getJSON(headerUrl), $.getJSON(tasksUrl), $.getJSON(testingTrackerUrl), $.getJSON(highlightsUrl))) .then(function(headerData, tasksData,testingTrackerData,highlightsData) { printData(headerData, tasksData,testingTrackerData,highlightsData); }) .fail(function(data, textStatus, jqXHR) { console.error('Got error in '+jqXHR); });
jquery deferred
user4300143
source share