-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
25 lines (22 loc) · 743 Bytes
/
script.js
File metadata and controls
25 lines (22 loc) · 743 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
function loadDoc(p, t) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById(t).innerHTML = this.responseText;
}
};
xhttp.open("GET", p, true);
xhttp.send();
}
function postReq(p) {
var xhttp = new XMLHttpRequest(); // new HttpRequest instance
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML = this.responseText;
}
};
var url = p;
xhttp.open("POST", url);
xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhttp.send(JSON.stringify({ "foo": "bar", "data": { "vin": "$VIN" } }));
}