async=false

This commit is contained in:
Gnieark 2016-06-07 09:34:37 +02:00
parent b8279dd421
commit bd194bac48

View File

@ -215,20 +215,17 @@ function startGame(){
//envoyer les requetes d'init aux bots //envoyer les requetes d'init aux bots
for (var p = 1; p < 3 ; p++){ for (var p = 1; p < 3 ; p++){
if(document.getElementById("player" + p + "Type").value == "bot"){ if(document.getElementById("player" + p + "Type").value == "bot"){
var xhr = new XMLHttpRequest();
var xhr = new XMLHttpRequest(); xhr.open("POST", document.getElementById('url' + p).value, false);
xhr.onreadystatechange = function(){if(xhr.readyState == 4){ xhr.setRequestHeader("Content-Type", "application/json");
if(xhr.status == 200) { xhr.send(' {"game-id":"1126","action":"init","game":"tictactoe","players":2,"board":"","player-index":' + (p - 1) +'}');
addLog('Message d\'init envoyé au bot player ' + p ); if(xhr.status == 200) {
}else{ addLog('Message d\'init envoyé au bot player ' + p );
addLog('player ' + p + ' n est pas joignable ' + xhr.status); }else{
return; addLog('player ' + p + ' n est pas joignable ' + xhr.status);
} return;
}}; }
xhr.open("POST", document.getElementById('url' + p).value, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(' {"game-id":"1126","action":"init","game":"tictactoe","players":2,"board":"","player-index":' + (p - 1) +'}');
} }
} }
play(1); play(1);