fixed async ajax running
This commit is contained in:
parent
e3a432cd5a
commit
d8b16984ef
@ -33,11 +33,11 @@ document.getElementsByClassName('play')[0].onclick = function startGame() {
|
|||||||
//*********************
|
//*********************
|
||||||
// TODO Get from server
|
// TODO Get from server
|
||||||
//*********************
|
//*********************
|
||||||
|
setTimeout
|
||||||
getInitial()
|
getInitial()
|
||||||
|
console.log(playerTeam);
|
||||||
|
console.log(playerCoordinate[0],playerCoordinate[1]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO IP Handling, most likely not necessary
|
// TODO IP Handling, most likely not necessary
|
||||||
|
|
||||||
var login = document.getElementById("login");
|
var login = document.getElementById("login");
|
||||||
@ -52,19 +52,17 @@ document.getElementsByClassName('play')[0].onclick = function startGame() {
|
|||||||
document.onkeydown = movePlayer;
|
document.onkeydown = movePlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setInitial(initial) {
|
|
||||||
playerCoordinate = initial["coordinate"];
|
|
||||||
playerTeam = initial["team"];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getInitial() {
|
function getInitial() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'http://127.0.0.1:5000/game',
|
url: 'http://127.0.0.1:5000/game',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
async: false,
|
||||||
// data: '',
|
// data: '',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
//called when successful
|
//called when successful
|
||||||
setInitial(data)
|
console.log(data["coordinate"], data["team"])
|
||||||
|
playerCoordinate = data["coordinate"];
|
||||||
|
playerTeam = data["team"];
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
//called when there is an error
|
//called when there is an error
|
||||||
@ -72,6 +70,7 @@ function getInitial() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function serverTransfer(coordinate,team,turn,username) {
|
function serverTransfer(coordinate,team,turn,username) {
|
||||||
var move = {
|
var move = {
|
||||||
coordinate: coordinate,
|
coordinate: coordinate,
|
||||||
@ -84,6 +83,7 @@ function serverTransfer(coordinate,team,turn,username) {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
type : "POST",
|
type : "POST",
|
||||||
data: JSON.stringify(move, null, '\t'),
|
data: JSON.stringify(move, null, '\t'),
|
||||||
|
async: false,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
contentType: 'application/json;charset=UTF-8'
|
contentType: 'application/json;charset=UTF-8'
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user