So I have the following code:
function ajax1(url) {
return $.ajax({
url: url
});
}
function ajax2(url) {
return $.ajax({
url: url
});
}
function ajax3(url) {
return $.ajax({
url: url
});
}
function ajax4(url) {
return $.ajax({
url: url
});
}
I then run the Ajax calls and access the data returned by each one using $.when
:
$.when(ajax1(url), ajax2(url), ajax3(url), ajax4(url)).done(function(a1, a2, a3, a4){
});
Now, let's say one of the Ajax calls, ajax2
, will return a 404 error.
How can prevent the script from executing and still return something (like false, to be accessed using the a2
variable) even when a 404 error is returned?
Thank you very much in advance.