Skip to content

Instantly share code, notes, and snippets.

@alsheuski
Created April 16, 2015 07:25
Show Gist options
  • Save alsheuski/94560107f491977375f1 to your computer and use it in GitHub Desktop.
Save alsheuski/94560107f491977375f1 to your computer and use it in GitHub Desktop.
Create native ajax-request
function createRequest() {
try{
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft){
try{
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
if (request == null) {
console.log("Error creating request object!");
}
return request;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment