Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Support of XDomainRequest #60

Closed
vincentbernat opened this issue Apr 8, 2012 · 2 comments
Closed

Support of XDomainRequest #60

vincentbernat opened this issue Apr 8, 2012 · 2 comments

Comments

@vincentbernat
Copy link
Contributor

Hi!

When doing cross-domain requests, IE8 and IE9 require to use XDomainRequest instead of XMLHttpRequest.

@vincentbernat
Copy link
Contributor Author

I tried to add support for XDomain request with something like this:

if (!(xhr && "withCredentials" in xhr) && (typeof XDomainRequest != "undefined")) {
  xhr = new XDomainRequest();
  xhr.onerror = xhr.onprogress = function() {};
  xhr.onload = function() {
    xhr.readyState = 4;
    xhr.onreadystatechange();
  }
}
xhr.open("GET", url);

I don't know if it works with crossdomain requests but it does not work non crossdomain requests (it triggers the onerror event and there seems to be no possibility to know why except guessing). Therefore, I didn't bother to try with crossdomain requests.

I know that setting the onprogress event if required for IE9 (otherwise, no other events will be triggered). I am in the blue for everything else.

Some pointers:

In the comments of the last one, I have asked if XDomainRequest should work with requests to the same domain without a CORS header.

@vincentbernat
Copy link
Contributor Author

Maybe the solution would be to try with XMLHttpRequest first, then fallback to XDomainRequest on errors.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants