Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Support of XDomainRequest #60

Closed
vincentbernat opened this Issue · 2 comments

2 participants

@vincentbernat

Hi!

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

@vincentbernat

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

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

@vincentbernat vincentbernat referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@LeaVerou LeaVerou closed this issue from a commit
@vincentbernat vincentbernat IE9: Fallback to XDomainRequest if available.
On IE9, `XMLHttpRequest` does not allow to do a crossdomain
request. An exception is triggered on `open()` in this case. We
intercept this exception and use `XDomainRequest` if available.

This should close #60.
1fcb5f5
@LeaVerou LeaVerou closed this in 1fcb5f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.