Created
July 18, 2014 10:50
-
-
Save denysdovhan/f12558c876f8f54f9a31 to your computer and use it in GitHub Desktop.
Return a XMLHttpRequest objects
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
/** | |
* Return a XMLHttpRequest objects | |
* @return {Object} XMLHttpRequest | |
*/ | |
function getXMLHttpRequest() { | |
if (window.XMLHttpRequest || window.ActiveXObject) { | |
if (window.XMLHttpRequest) { | |
return new XMLHttpRequest(); | |
} else { | |
try { | |
return new ActiveXObject('Msxml2.XMLHTTP'); | |
} catch (e) { | |
return new ActiveXObject('Microsoft.XMLHTTP'); | |
} | |
} | |
} | |
console.log('Browser does not support AJAX.'); | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment