Questions :
- Should we change our coding as suggested below?
- Is there a difference between
.done() and success: .fail() and error: and .always() and complete: :?
Preamble :
I collected the jQuery.ajax call, which I have successfully done in the past. Something like that:
$.ajax( { url: someUrl, type: 'POST', data: someData, datatype: 'json', success: function (data) { someSuccessFunction(data); }, error: function (jqXHR, textStatus, errorThrown) { someErrorFunction(); } });
After carefully reviewing some of the documentation, I came across a link stating that successful, erroneous, and complete callbacks are deprecated from jQuery 1.8. To prepare the code for possible removal, use jqXHR.done (), jqXHR.fail (), and jqXHR.always () instead.
Therefore, we should start coding something like this:
$.ajax( "example.php" ) .done(function (data) { someSuccessFunction(data); }) .fail(function (jqXHR, textStatus, errorThrown) { someErrorFunction(); }) .always(function() { alert("complete"); });
javascript jquery ajax
PostureOfLearning Aug 16 '13 at 1:02 2013-08-16 01:02
source share