Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can anyone tell me what is the difference between jquery ajax fail and error.
in which condition fail and in which condition error should be use. give a example code.
please help.
i try to find the solution on google, but i don't get any suitable solution.
Posted

1 solution

According to the documentation[^], fail is an alternative construct for the error callback. It's used to implement the Javascript "Promise" interface[^].

The jqXHR objects returned by $.ajax() as of jQuery 1.5 implement the Promise interface, giving them all the properties, methods, and behavior of a Promise (see Deferred object[^] for more information). These methods take one or more function arguments that are called when the $.ajax() request terminates. This allows you to assign multiple callbacks on a single request, and even to assign callbacks after the request may have completed. (If the request is already complete, the callback is fired immediately.)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900