Skip to content

Instantly share code, notes, and snippets.

@andreban
Created November 5, 2014 15:11
Show Gist options
  • Save andreban/2f249ff1f9b45f2c5300 to your computer and use it in GitHub Desktop.
Save andreban/2f249ff1f9b45f2c5300 to your computer and use it in GitHub Desktop.
Creating a CORS Request that Works on IE 8 and IE 9
function createCORSRequest(method, url){
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr){
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined"){
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
return xhr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment