在跨域调用的IE中,Jquery $ .ajax失败

在跨域调用的IE中,Jquery $ .ajax失败

我正在使用跨域请求$.ajax。它适用于Firefox和Chrome,但不会在IE 7或8上发出呼叫。任何人都可以告诉我以下内容有什么问题吗?

  1. 我使用了JSON和JSONP(由于一些自定义限制,我停止使用它)。

  2. 我已经Allow-access-control-origin在我的网站上使用标题了。(没有这些,Chrome和Firefox没有成功请求。)

  3. 我已经尝试过https://developer.mozilla.org/en/http_access_control

码:

$.ajax({
    type: 'GET',
    url: "http://anotherdomain.com/Service/GetControl?id=" + zoneID,
    cache: false,
    contentType: "application/x-www-form-urlencoded",
    async: false,
    beforeSend: function (request) {
        //alert('before send');
        //request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
        //request.setRequestHeader("X-PINGOTHER", "pingpong");
    } ,
    success: function (data, status) {
        //alert("Data returned :" + data);
        //alert("Status :" + status);
        if (status == "success" && data != "")
            $("#" + div.id).append(data);
        else
            $("#" + div.id).attr("style", "display:none;");
    },
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        alert(textStatus);
        alert(errorThrown);
    }});

我尝试了多个网站上的各种提示,但还没有运气。


绝地无双
浏览 444回答 3
3回答

四季花海

只需安装这个jQuery插件:用于IE8的jQuery跨域AJAX这个1.4kb的插件可以立即在Internet Explorer 8和9中运行。在jQuery之后包含插件,并正常调用你的ajax请求。没有其他要求。插件GitHub repo和安装说明
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JQuery