Skip to content

Instantly share code, notes, and snippets.

@nathanpc
Created June 18, 2011 15:58
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 nathanpc/1033219 to your computer and use it in GitHub Desktop.
Save nathanpc/1033219 to your computer and use it in GitHub Desktop.
Compatible AJAX Object Initialization
function initAjax() {
var objXml = false;
if(window.XMLHttpRequest) {
objXml = new XMLHttpRequest(); // All modern browsers
} else if(window.ActiveXObject) {
try {
objXml = new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer 6
} catch(e) {
try {
objXml = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer 5
} catch(ex) {
objXml = false;
}
}
}
return ObjXml;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment