简体   繁体   English

jQuery ajax不适用于ie8

[英]jQuery ajax doesn't work on ie8

I have this call: 我有这个电话:

$.ajax({dataType: "json",
        url: '<url_here>',
        cache: false,
        success: function(data, textStatus, jqXHR ) {
            success(data, textStatus, jqXHR);
        }
});

That works on every browser ou there... except on IE :( (I'm testing version 8) The success function is never called so it looks like the function (.ajax) isn't executed right (or at all). Anyone know anything about jquery ajax on ie 8? 这适用于每个浏览器......除了IE :((我正在测试版本8)成功函数永远不会被调用,所以看起来函数(.ajax)没有正确执行(或根本没有)。任何人都知道有关jquery ajax的事情,即8?

OK, this ones are always good, where one answer to himself :) 好的,这些总是好的,一个人回答自己:)

The problem was that looks like IE doesn't parse the headers from the ajax'ed site. 问题是看起来像IE不解析ajax'ed网站的标题。 So as this was a cross domain request, it was allowing it to get through. 因此,这是一个跨域请求,它允许它通过。 So, I had to activate "Access data sources across domain" on IE security settings. 因此,我必须在IE安全设置上激活“跨域访问数据源”。 On other browsers, just adding the header Access-Control-Allow-Origin: * would allow for cross site scripting, just not on IE. 在其他浏览器上,只添加标题Access-Control-Allow-Origin:*将允许跨站点脚本,而不是在IE上。

One other thing I had to add to the script was: jQuery.support.cors = true; 我必须添加到脚本的另一件事是:jQuery.support.cors = true;

or I would get "No transport available" 或者我会得到“没有交通工具”

This is because, my default, IE8 doesn't support JSON. 这是因为,我的默认IE8不支持JSON。 You need to include the json2 library in your project. 您需要在项目中包含json2库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM