Internet Explorer 首次无法访问 JSON Web 服务
我在使用 Internet Explorer 和 JSON Web 服务时遇到了问题,想知道其他人是否也遇到过这样的问题。使用 jQuery,我尝试访问返回 JSON 数据的同一域上的特定 URL。这在 Firefox 和 Chrome 上完美运行。但是,在 Internet Explorer 中,第一个 Ajax 请求总是失败。更有趣的是,后续 Ajax 请求确实有效,即使请求来自同一个函数!
起初,我以为我可能在 jQuery 上做错了什么,但是......当我尝试使用 Internet Explorer 访问我的 JSON Web 服务 URL(直接进入新选项卡上的地址栏)时,它第一次也失败了,并且之后成功。因此我认为这可能是我的 Web 服务的问题,但随后我对 Internet 上免费提供的 Web 服务也遇到了同样的问题。每次我打开新选项卡并尝试访问 JSON Web 服务时,第一次调用总是失败。
有人在使用 Internet Explorer 和 JSON Web Service 时遇到过同样的问题吗?我关注的是错误的问题:IE 无法访问 Web 服务的问题是否无关紧要,而 jQuery 的问题在其他地方?
我的AJAX调用编写如下:
$.ajax({
async: true,
type: 'GET',
url: '<JSON Web service URL>',
dataType: 'json',
cache: false, // Doesn't help
success: function(data, textStatus, xhr) {
alert('success');
},
error: function(xhr, textStatus, error) {
alert('failure');
}
});
我已经在几种配置上尝试过这一点,但问题始终存在:
- Windows XP / 7
- Internet Explorer 7(真实和IE 8模拟模式)/ 8
- Chrome 11
- Firefox 4
- jQuery 1.5.1 / 1.5.2
预先感谢,
I have encountered a problem with Internet Explorer and JSON Web Services and was wondering if anyone else has as well. Using jQuery, I tried to access a specific URL on the same domain that returns JSON data. This works perfectly on Firefox and Chrome. However, the first Ajax request always fails in Internet Explorer. What's more interesting is that subsequent Ajax requests DO work, even though the request emanates from the same function!
At first, I thought that I might have done something wrong with jQuery but ... when I tried accessing my JSON Web service URL using Internet Explorer (directly into the address bar on a new tab), it also fails the first time, and succeeds afterwards. So I thought that it might be a problem with my Web service, but then I have the same issue with Web services available freely on the Internet. Every time I open a new tab and try to access a JSON Web service, the first call always fails.
Did anyone experience the same problem with Internet Explorer and JSON Web Service? I am focusing on the wrong problem: is the issue with IE not capable of accessing the Web service irrelevant, and the problem with jQuery is somewhere else?
My AJAX call is written as follows:
$.ajax({
async: true,
type: 'GET',
url: '<JSON Web service URL>',
dataType: 'json',
cache: false, // Doesn't help
success: function(data, textStatus, xhr) {
alert('success');
},
error: function(xhr, textStatus, error) {
alert('failure');
}
});
I've tried this on several configurations, but the problem is always there:
- Windows XP / Seven
- Internet Explorer 7 (Real and IE 8 Emulated mode) / 8
- Chrome 11
- Firefox 4
- jQuery 1.5.1 / 1.5.2
Thanks in advance,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题,将 jQuery 更新到 1.6.4 解决了这个问题:)
I was facing same issue, updating jQuery to 1.6.4 solved the issue :)