Skip to content

Instantly share code, notes, and snippets.

@julsfelic
Created April 20, 2013 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julsfelic/5426353 to your computer and use it in GitHub Desktop.
Save julsfelic/5426353 to your computer and use it in GitHub Desktop.
Cross-Browser CORS
function createCORSResquest(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;
}
var request = createCORSRequest();
if (request) {
request.onload = function() {
};
request.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment