我怀疑每隔一段时间,我的 $.ajax 调用不会返回完成或失败。那可能吗?它根本就没有返回吗?
我怀疑的原因是因为我将发送到服务器的行标记为已发送,其中一些行被发送了两次。
最佳答案
jQuery 支持:
.done()
.fail()
.always()
.then()
I have a suspicion that every once in a while, my $.ajax call doesn't return with either a done or a fail. Is that possible? That it just doesn't return at all?
除非您的代码或 jQuery 代码中存在某些异常,会中止预期代码路径的执行,否则 .done()
或 .fail 都不应该出现()
被调用。 应该调用其中一个。
.always()
与 .done()
或 .fail()
一起调用。
.then()
接受两个回调函数,是 .done()
和 .fail()
的 Promise 标准替代品。
有一些较旧的、已弃用的函数,例如 .success()
,但它们不会影响 .done()
或 .fail()
工作。
关于jquery - 除了完成和失败之外,$.ajax 是否还有第三个选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33486213/