Embezzle/client/Old/index.js

30 lines
931 B
JavaScript
Raw Normal View History

2020-03-08 13:10:10 +00:00
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()
}