gpt4 book ai didi

javascript - $.ajax 在 IE6 上无法正常工作

转载 作者:行者123 更新时间:2023-11-29 10:25:40 25 4
gpt4 key购买 nike

基本上,我有这样的东西:

$.ajax({
type: "GET",
url: "my_url",
cache: true,
success: function(data) {
/* code here */
},
dataType: 'json'
});

此代码在所有经过测试的浏览器(IE7/8、chrome、safari、firefox)中均有效,但在 IE6 中未调用成功函数。

我使用 Fiddler 查看 HTTP 请求中发生了什么,一切似乎都很正常,我得到了预期的结果作为 HTTP 应答,但在 IE6 中似乎没有调用成功,对于 onerror 也是如此。

有什么想法吗?

最佳答案

尝试使用 complete 而不是 success。如果它持续触发,那么您可以评估状态代码以确定它是否成功...

$.ajax({
type: "GET",
cache: true,
complete: function(xhr) {
if(xhr.status != 200) {
throw "Error!";
return;
}

var data = xhr.responseText;
}
});

关于javascript - $.ajax 在 IE6 上无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1952818/

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