gpt4 book ai didi

javascript - 中止 ajax 调用?

转载 作者:行者123 更新时间:2023-11-28 13:23:47 27 4
gpt4 key购买 nike

我的 currentReq var 设置为回调方法:

this.currentReq = cb.apply(this,args);

稍后,如果是 ajax 调用,我可能希望中止该方法。

我知道我可以使用:

this.currentReq.abort();

但是如果 currentReq 不是 ajax 调用怎么办?我如何测试这个并且仅在 ajax 调用时中止?当我尝试在标准延迟上中止时出现错误。

最佳答案

您可以先测试一下abort方法是否存在:

if (typeof(this.currentReq.abort) == "function") {
this.currentReq.abort();
}

关于javascript - 中止 ajax 调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30990057/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com