Skip to content

Instantly share code, notes, and snippets.

@jwalsh
Forked from anonymous/3rdparty-Listing4-8.js
Created May 2, 2012 18:22
Show Gist options
  • Save jwalsh/2578936 to your computer and use it in GitHub Desktop.
Save jwalsh/2578936 to your computer and use it in GitHub Desktop.
Listing 4.8
function makeRequest(url, method) {
var xhr;
if (typeof XMLHttpRequest === "undefined") {
return null;
}
xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
return xhr;
};
if (typeof XDomainRequest === "undefined") {
return null;
}
xhr = new XDomainRequest();
xhr.open(method, url);
return xhr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment