最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AJAX cross-domain request IE 8+ - Stack Overflow

programmeradmin4浏览0评论

How to correct rewrite the Ajax request to make it work in IE 8 +, using XDomainRequest?

$.ajax({
    type: "GET",
    url: url,
    success: function(xml) {
        $('.post-msg').append(processXml(xml, config));
    },
    error: function(jqXhr, textStatus, errorThrown) {
        var errorMsg = "Request on url: " + url + " failed: " + textStatus + " error:" + errorThrown;
        alert(errorMsg);
    }
});

How to correct rewrite the Ajax request to make it work in IE 8 +, using XDomainRequest?

$.ajax({
    type: "GET",
    url: url,
    success: function(xml) {
        $('.post-msg').append(processXml(xml, config));
    },
    error: function(jqXhr, textStatus, errorThrown) {
        var errorMsg = "Request on url: " + url + " failed: " + textStatus + " error:" + errorThrown;
        alert(errorMsg);
    }
});
Share asked Jul 9, 2013 at 14:00 Geray SuinovGeray Suinov 3,7013 gold badges17 silver badges19 bronze badges 4
  • possible duplicate of Cross domain ajax request – Andrew Lewis Commented Jul 9, 2013 at 14:05
  • Does the site support JSONP? I know jQuery does not support cors for IE 8 and 9 because the xmlhttprequest of these browsers do not support it and because all the quirks that e with the special object that IE 8 (and I think IE 9) have with CORS the jQuery team have descided not to create that other object. So if the site has JSONP then use that if it has CORS then write your own xhr request but will still be buggy in IE 8 or 9. – HMR Commented Jul 9, 2013 at 14:05
  • 1 CORS with jQuery and XDomainRequest in IE8/9 has some very helpful background and library links. – apsillers Commented Jul 9, 2013 at 14:10
  • @apsillers That concludes that CORS isn't worth considering when you want to support IE 8 and 9. The same conclusion the jQuery team came to and the reason why they don't use xDomainRequest. – HMR Commented Jul 9, 2013 at 14:15
Add a ment  | 

1 Answer 1

Reset to default 5

Use this plugin for IE8-9 Xdomain support.

https://github./MoonScript/jQuery-ajaxTransport-XDomainRequest

发布评论

评论列表(0)

  1. 暂无评论