-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.html
29 lines (28 loc) · 908 Bytes
/
app.html
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
<h5>Start Ad-Placer!</h5>
<input type="submit" value="POST" onclick="submitPOST('query_param')" />
<input type="submit" value="GET" onclick="submitGET()" />
<script type="text/javascript">
function submitPOST(name) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
//alert(xhr.response);
console.log(xhr.response);
}
};
xhr.open("post", "http://127.0.0.1:5000/post/" + name, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify('{"data":"body is here"}'));
}
function submitGET() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
//alert(xhr.response);
console.log(xhr.response);
}
};
xhr.open("get", "http://127.0.0.1:5000/get", true);
xhr.send();
}
</script>