I need to wait multiple deferred to complete and then process my success or failed callback.
function myFunc(){
alert("Success");
}
function myFailure(){
alert("Failure");
}
var jqxhr = $.ajax( "example.cfm" )
.done(function() { alert("Primo report"); })
.fail(function() { alert("Primo report non completato"); })
.always(function() { alert("Finito prima chiamata"); });
var jqxhr2 = $.ajax( "example2.cfm" )
.done(function() { alert("Secondo report"); })
.fail(function() { alert("Secondo report non completato"); })
.always(function() { alert("Finito seconda chiamata"); });
var jqxhr3 = $.ajax( "example3.cfm" )
.done(function() { alert("Terzo report"); })
.fail(function() { alert("Terzo report non completato"); })
.always(function() { alert("Finito terza chiamata"); });
$.when(jqxhr,jqxhr2,jqxhr3)
.then(myFunc, myFailure);
The problem is that if one of my ajax request fail, immediately is fired the callback.
It's possible to wait until all the ajax request are complete and then callback?