IE 10 & 11 CORS Status 0

2020-07-18 06:21发布

问题:

I have an IE bug I can't seem to figure out. I am supporting IE 10 and 11 only so I thought I could get away with the following code.

I have an AJAX request:

$.ajax({
    type: {method},
    url: {url},
    cache: false,
    crossDomain: true,
    data: {data to send},
    success: function (data, textStatus, xhr) {
       ///success code
    },
   error: function (xhr, textStatus, errorThrown) {
       //error code
   }
});

This code works great in Firefox and Chrome. It doesn't work in IE 10,11. I was under the impression that CORS was fixed in IE 10,11 no?

Why do I get the follow error in IE 10,11?

{"readyState":0,"status":0,"statusText":"Error: Access is denied.\r\n"}

回答1:

So I needed to enable 'Access data sources across domains'.

Steps:

  1. Select Internet Options
  2. Select the Security Tab
  3. Select Custom level...
  4. Scroll down to Miscellaneous
  5. Find Access data sources across domains
  6. Change the value to Enable