function request(options) {
|
var oReq = new XMLHttpRequest();
|
oReq.open("GET", options.url, false);
|
oReq.responseType = options.type;
|
oReq.onload = function (result) {
|
if (result) {
|
var _data = null;
|
if (oReq.responseType == "text" || oReq.responseType == "") {
|
_data = result.target.responseText;
|
} else {
|
_data = result.target.response;
|
}
|
if (result.target.status == 200) {
|
if (typeof options.success == "function")
|
options.success(_data);
|
} else {
|
if (typeof options.error == "function") options.error(_data);
|
}
|
}
|
};
|
oReq.send(null);
|
oReq.onloadend = function () {
|
oReq = null;
|
};
|
}
|