简体   繁体   中英

angularjs http + script7002: xmlhttprequest: network error 0x80070005, access is denied

I am using angularjs for front end. Sever side node js. Frontend and Backend are different servers. When I post the http method getting error only in IE browsers.

Error Details:

script7002: xmlhttprequest: network error 0x80070005, access is denied.

sample code in angularjs

//var spec = form data:
    $http.post('https://test.com/account/register', spec)
            // handle success
            .success(function(data, status) {
                deferred.resolve(data);
            })
            // handle error
            .error(function(data) {
                deferred.reject(data);
            });

Front design setup in apache.

I referred this URL . Its working fine for me.

The solution that I've been able to achieve via the guidance of an experienced ng-dev at the Google AngularJS group is this xDomain library .

The setup is very simple, simply place a proxy.html file at the root of your API, with a regex/string for an allowed origin('master'), and a reference to the script at the frontend, and then point to this file from your frontend script('master').

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

Works like a charm with both $http and $resource.

You can also maintain normal functioning for normal browsers by placing the script above all JavaScript library includes:

<!--[if lte IE 9]>
<script src="xdomain.js" slave="http://example.org/proxy.html"></script>
<![endif]-->

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM