Are there any technical differences between the following callback methods?
1
$.ajax({
...
success: function(data, textStatus, jqXHR) {
foo(data);
},
error: function (jqXHR, textStatus, errorThrown ) {
bar();
}
});
2
$.ajax(...)
.done(function(data) {
foo(data);
})
.fail(function() {
bar();
});
3
$.ajax(...)
.then(function(data) {
foo(data);
}, function() {
bar();
});
With little experience, I am not sure they are correct examples for passing data to foo(). (Please correct me if I am wrong.)
With done/fail, we can't track other data like jqXHR, textStatus, errorThrown, etc. Am I right?
Is there a complete equivalence for the done/fail method?
From your experience, is one better than/preferred over the others at certain situations?
If I use both success and done/then, will one run before the other definitely or it can't be certain which will run before the other definitely? Or is using success and done/then altogether not recommended?