Skip to content

@Raynos /gist:1724574
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
var xhr = (function() {
var XHR = function() {
var xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
this.xmlhttp = xmlhttp;
};
XHR.prototype.post = function(options) {
this.request.apply(this, ["POST", options]);
};
XHR.prototype.get = function(options) {
this.request.apply(this, ["GET", options]);
};
XHR.prototype.request = function(type, options) {
if (this.xmlhttp) {
var _xhr = this.xmlhttp;
_xhr.open(type, options.url, true);
_xhr.onreadystatechange = function() {
if (_xhr.readyState == 4) {
options.success.apply(this, [_xhr.responseText]);
}
// add failure callback
};
_xhr.send(null);
}
};
return new XHR();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.