-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathajax.js
More file actions
29 lines (27 loc) · 781 Bytes
/
ajax.js
File metadata and controls
29 lines (27 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function AJAXGetRequest(file, getstr, callback) {
var xhr = new XMLHttpRequest();
// xhr.withCredentails = true;
if (getstr != '') {
var s = file + '?' + getstr;
} else {
s = file;
}
xhr.open("GET", s, true);
xhr.onreadystatechange = function() {
if ((xhr.readyState == 4) && (xhr.status == "200")) {
callback(xhr.responseText);
}
}
xhr.send(null);
}
function AJAXPostRequest(file, fD, callback) {
var xhttp = new XMLHttpRequest();
// xhttp.withCredentails = true;
xhttp.open("POST", file, true);
xhttp.onreadystatechange = function() {
if ((xhttp.readyState == 4) && (xhttp.status == "200")) {
callback(xhttp.responseText);
}
}
xhttp.send(fD);
}