Skip to content

Instantly share code, notes, and snippets.

@denysdovhan
Created July 18, 2014 10:50
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 denysdovhan/f12558c876f8f54f9a31 to your computer and use it in GitHub Desktop.
Save denysdovhan/f12558c876f8f54f9a31 to your computer and use it in GitHub Desktop.
Return a XMLHttpRequest objects
/**
* 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