Call to jquery ajax - .fail vs. :error

后端 未结 3 1040
悲哀的现实
悲哀的现实 2020-12-04 17:07

Which one should I use?

Is there any reason to use one rather than the other?

Is one better for error handling?

$.ajax({
    url: url,
             


        
3条回答
  •  感情败类
    2020-12-04 17:51

    Just to freshen this up...

    The success and error approach have been deprecated as of jQuery 1.8.

    jQuery Ajax

    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.

提交回复
热议问题