jquery ajax中的失败和错误有什么区别 [英] what is the difference between fail and error in jquery ajax

查看:117
本文介绍了jquery ajax中的失败和错误有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我jquery ajax失败和错误之间有什么区别。

哪个条件失败以及应该使用哪个条件错误。给出一个示例代码。

请帮忙。

i尝试在谷歌上找到解决方案,但我没有得到任何合适的解决方案。

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.

推荐答案

根据文档 [ ^ ],失败是<$的替代构造c $ c>错误回调。它用于实现 JavascriptPromise界面 [ ^ ]。

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



从jQuery 1.5开始,


The jqXHR objects returned by


.ajax()返回的jqXHR对象实现了Promise接口,为它们提供了Promise的所有属性,方法和行为(参见延期对象 [ ^ ]获取更多信息)。这些方法接受一个或多个函数参数,这些参数在
.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()请求终止时调用。这允许您在单个请求上分配多个回调,甚至在请求完成后分配回调。 (如果请求已经完成,则立即触发回调。)

.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.)


这篇关于jquery ajax中的失败和错误有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆