admin管理员组

文章数量:1327680

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

本文标签: javascriptAJAX crossdomain request IE 8Stack Overflow