Skip to content

Instantly share code, notes, and snippets.

@yocontra
Created May 16, 2012 10:49
Show Gist options
  • Save yocontra/2709462 to your computer and use it in GitHub Desktop.
Save yocontra/2709462 to your computer and use it in GitHub Desktop.
Tiny XMLHTTPRequest shim
var ids = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP", "Msxml2.XMLHTTP.4.0"];
if (typeof XMLHttpRequest === "undefined") {
for (var i = 0; i < ids.length; i++) {
try {
new ActiveXObject(ids[i]);
window.XMLHttpRequest = function() {
return new ActiveXObject(ids[i]);
};
break;
} catch (e) {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment