最佳答案
The questions:
.done()
& success:
, .fail()
& error:
and .always()
& complete:
?The preamble:
I was putting together a jQuery.ajax call, which I have done successfully in the past too. Something like this:
$.ajax(
{
url: someUrl,
type: 'POST',
data: someData,
datatype: 'json',
success: function (data) { someSuccessFunction(data); },
error: function (jqXHR, textStatus, errorThrown) { someErrorFunction(); }
});
While taking a quick look at some documentation, I came across a reference stating that The success, error and complete callbacks are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.
We should therefore start coding something like this instead:
$.ajax( "example.php" )
.done(function (data) { someSuccessFunction(data); })
.fail(function (jqXHR, textStatus, errorThrown) { someErrorFunction(); })
.always(function() { alert("complete"); });