Since jQuery 1.5 - jqXHR objects returned by $.ajax() implement the Promise interface.
The docs also state that jqXHR.done , jqXHR.fail , jqXHR.always are alternative constructs for the deprecated success / fail/ complete respectively.
Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.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.
ok.(known a long time ago)
But then I saw the async doc :
async : As of jQuery 1.8, the use of
async: falsewithjqXHR ($.Deferred)is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such asjqXHR.done()or thedeprecated jqXHR.success().
The wording here are very unclear (imho) - thus , I don't understand the meaning of it.
Question :
Are there any situations which still I need to use success/error/complete ? how come ? they are deprecated !
nb , why all this mess ? they change and remove methods and replace(! eg pipe , then) like every version
What is deprecated is using async: false and jqXHR ($.Deferred) API at same time (The combining usage).
The success/error/complete callback options of $.ajax() are not deprecated.
The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated.
When using async AJAX request (async: true), you could use either success/error/complete callback options of $.ajax() or jqXHR.done, jqXHR.fail , jqXHR.always.
But when using synchronous AJAX requests(async: false),
you should not use the deferred API(jqXHR.done, jqXHR.fail , jqXHR.always),
but use success/error/complete callback options of $.ajax().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With