cuốn sách gpt4 ai đã làm

javascript - 中止 ajax 调用?

In lại Tác giả: Walker 123 更新时间:2023-11-28 13:23:47 27 4
mua khóa gpt4 Nike

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

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

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

我知道我可以使用:

this.currentReq.abort();

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

câu trả lời hay nhất

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

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

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

27 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress