Backbone fetch() fails for IE

2019-08-12 05:13发布

问题:

I am using Backbone's fetch to get data from a remote server. It works fine for all browsers but IE (of course), as IE requires you to use XDomainRequest instead of XHR for cross site. Do I have to replace every fetch in the application with something like the below code?

 var xdr = new XDomainRequest();
        xdr.open("get", url);
        xdr.onload = function() {
            // XDomainRequest doesn't provide responseXml, so if you need it:
            var dom = new ActiveXObject("Microsoft.XMLDOM");
            dom.async = false;
            dom.loadXML(xdr.responseText);

        };

        xdr.onsuccess = success;
        xdr.onerror=error;
        xdr.send();

I am also geting a SCRIPT5: "Access is denied" error when I am using the above code.

Is it possible that backbone fetch is not handled properly in IE or am I doing something wrong?

回答1:

We are trying to make it work with node.js server.

There is module node-http-proxy for node.js , we are setting up a proxy server which is intercepting all the calls.

So when there is call from IE 8/9 we will modify it.