30 lines
931 B
JavaScript
30 lines
931 B
JavaScript
|
url="http://127.0.0.1:3000"
|
||
|
|
||
|
function send() {
|
||
|
data = {name: $('#name').val(), ownerID: $("#ownerID").val(), gameID: $("#gameID").val(), seats: $("#seats").val()}
|
||
|
console.log(JSON.stringify(data))
|
||
|
let xhr = new XMLHttpRequest();
|
||
|
xhr.open("POST", url + "/" + $('#location').val(), true)
|
||
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
||
|
xhr.onreadystatechange = function () {
|
||
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
||
|
|
||
|
console.log(JSON.parse(xhr.responseText))
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
xhr.send(JSON.stringify(data))
|
||
|
}
|
||
|
|
||
|
function get() {
|
||
|
let xhr = new XMLHttpRequest();
|
||
|
xhr.open("GET", url + "/" + $('#location').val(), true)
|
||
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
||
|
xhr.onreadystatechange = function () {
|
||
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
||
|
console.log(JSON.parse(xhr.responseText))
|
||
|
}
|
||
|
}
|
||
|
xhr.send()
|
||
|
}
|