jQuery AJAX 请求在 IE 中失败 [英] jQuery AJAX request failing in IE

查看:27
本文介绍了jQuery AJAX 请求在 IE 中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下 AJAX 调用在 IE 中失败.

The following AJAX call is failing in IE.

$.ajax({
    url:"{{SITE_URL}}/content/twitter.json",
    dataType:"json",
    error:function(xhr, status, errorThrown) {
        alert(errorThrown+'
'+status+'
'+xhr.statusText);
    },
    success:function(json) {
               ...Snip...
    }
});

错误函数返回

Undefined
parsererror
OK

没有向服务器发出请求,所以我认为这不是 JSON 的问题.

No request is made to the server so I don't think its a problem with the JSON.

已修复,请参阅 #1351389

推荐答案

已修复,我从 application/json 更改了 content-type;charset=utf8 到简单的 application/json.
我讨厌 IE :)

Fixed, I changed the content-type from application/json; charset=utf8 to just plain application/json.
I hate IE :)

为了避免 IE 超级缓存,试试这个:

Also to avoid IE super-caching try this:

var d = new Date();
$.ajax({
        url:"{{SITE_URL}}/content/twitter.json?_="+d.getTime(), 
...Snip...

这样每个请求都是 IE 获取的新 url :D

That way each request is a new url for IE to get :D

这篇关于jQuery AJAX 请求在 IE 中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆