mirror of
https://github.com/sigmasternchen/JSTools
synced 2025-03-15 16:28:56 +00:00
36 lines
981 B
JavaScript
36 lines
981 B
JavaScript
var AjaxConnector = function() {
|
|
}
|
|
AjaxConnector.reqGet = function(file, pars, bg, after) {
|
|
var http = new XMLHttpRequest();
|
|
http.open("GET", "ajax/" + file + ".php?" + pars, bg);
|
|
if (bg) {
|
|
http.onreadystatechange = function() {
|
|
if (http.readyState == 4) {
|
|
after(http.responseText);
|
|
}
|
|
};
|
|
}
|
|
http.send(null);
|
|
if (!bg)
|
|
return after(http.responseText);
|
|
}
|
|
AjaxConnector.reqPost = function(file, get, pars, bg, after) {
|
|
var http = new XMLHttpRequest();
|
|
http.open("POST", "ajax/" + file + ".php?" + get, bg);
|
|
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
|
http.setRequestHeader("Content-length", pars.length);
|
|
http.setRequestHeader("Connection", "close")
|
|
if (bg) {
|
|
http.onreadystatechange = function() {
|
|
if (http.readyState == 4) {
|
|
after(http.responseText);
|
|
}
|
|
};
|
|
}
|
|
http.send(pars);
|
|
if (!bg)
|
|
return after(http.responseText);
|
|
}
|
|
AjaxConnector.reqCrossDomainGet = function(host, file, get, bg, after) {
|
|
// TODO
|
|
}
|