Created
April 16, 2015 07:25
-
-
Save alsheuski/94560107f491977375f1 to your computer and use it in GitHub Desktop.
Create native ajax-request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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