-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrazax.js
24 lines (24 loc) · 1002 Bytes
/
razax.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var rx = rx || {};
rx.zhr = function (servermethod, successcall,calltype) {
if (typeof servermethod === 'undefined' || typeof successcall === 'undefined' || typeof calltype === 'undefined') {
console.log('all paramters not provided');
} else {
this.servermethod = servermethod;
this.successcall = successcall;
}
this.constructor.prototype.do = function (clientobject) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open(calltype, this.servermethod, true);
xmlHttp.setRequestHeader("Content-type", "application/json; charset=utf-8");
xmlHttp.onreadystatechange = function ParseResult(ReturnVal) {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
window[successcall](JSON.parse(xmlHttp.responseText));
}
}
if (typeof clientobject === 'undefined') {
xmlHttp.send();
} else {
xmlHttp.send(JSON.stringify(clientobject));
}
};
};