Skip to content

Instantly share code, notes, and snippets.

@englishextra
Last active September 14, 2016 12:41
Show Gist options
  • Save englishextra/d5ce0257afcdd9a7387d3eb26e9fdff5 to your computer and use it in GitHub Desktop.
Save englishextra/d5ce0257afcdd9a7387d3eb26e9fdff5 to your computer and use it in GitHub Desktop.
Load .html file
/*!
* Load .html file
* modified JSON with JS.md
* gist.github.com/thiagodebastos/08ea551b97892d585f17
* gist.github.com/englishextra/d5ce0257afcdd9a7387d3eb26e9fdff5
*/
var AJAXloadHTML = function (u, cb, e) {
var w = window,
x = w.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
x.overrideMimeType("text/html;charset=utf-8");
x.open("GET", u, !0);
x.onreadystatechange = function () {
if (x.status == "404") {
e && "function" === typeof e && e();
console.log("Error XMLHttpRequest-ing file", x.status);
return !1;
} else if (x.readyState == 4 && x.status == 200 && x.responseText) {
cb && "function" === typeof cb && cb(x.responseText);
}
};
x.send(null);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment