Access to XMLHttpRequest denied using AngularJS for any version of IE below 10

When viewing my application in any Microsoft IE browser version greater than 10, I get the following strange error on the console:

console screen shot from the developer console, the view doesn't get resolved due to this error

I tried to cancel the console by adding the following JavaScript code to the AngularJS lib version:

console.log = function(){}; window.console = {log: function(){}}; 

It didn’t matter. The same error in IE 10 looks like:

 SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied. 

Maybe I'm trying to get "/ me" from the API to check if the user or guest is authenticated.

Basically. fixing these annoying console errors every time the server gives a response other than 2XX or 3XX will be wonderful!

UPDATE: it seems that this is due to access to the API through another subdomain (CORS);

+44
angularjs internet-explorer cors
Sep 09 '13 at 20:09 on
source share
3 answers

The solution I managed to achieve with the help of experienced ng-dev in the Google AngularJS group is the xDomain library .

The setup is very simple, just put the proxy.html file in the root of your API, with a regular expression / line for the permitted source ("master") and a script link in the external interface, and then specify this file from the external interface of the script ('master') .

It works by opening the proxy.html file in an iframe and interacting with the CORS resource using postMessage .

Works like a charm with $ http and $ resource.

You can also support normal operation for regular browsers by placing the script primarily in the JavaScript library:

 <!--[if lte IE 9]> <script src="xdomain.js" slave="http://example.org/proxy.html"></script> <![endif]--> 
+73
Sep 16 '13 at 9:32 on
source

Of course, your problem is with CORS. IE10 uses real XmlHttpRequest, but before that IE didn’t. By far, the easiest way to solve these problems is to use apache or nginx for the proxy API. For example, with nginx, on your server {} block:

 location /api { proxy_pass http://my.server.name:12345/v1; proxy_redirect off; } 

Please note that even jQuery does not support XDomainRequest and CORS directly, you need to add a plugin to get XDR. Also note: XDR has some serious limitations regarding CORS.

+4
09 Sep '13 at 23:23
source

In my case, the Response Headers contained

Content-Type:application/json; charset=UTF-8

and this is a problem for IE9, as it cannot properly handle / parse JSON objects in responses.

Toggle Response Headers in

Content-Type:text/plain; charset=UTF-8

Also, make sure that the following module is enabled for IE9: https://stackoverflow.com/a/167295/

allowed to receive a response in the text and then convert it to a JSON object.

-one
03 Sep '15 at 14:49
source



All Articles