Skip to content

Instantly share code, notes, and snippets.

@beradrian
Forked from yocontra/xmlhttprequest.js
Created November 25, 2015 15:17
Show Gist options
  • Save beradrian/5d30bcbf7e8e0d9b5090 to your computer and use it in GitHub Desktop.
Save beradrian/5d30bcbf7e8e0d9b5090 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