verif JSON format

This commit is contained in:
gnieark 2016-06-03 12:06:27 +02:00
parent ca56fab131
commit b0f5e6a36e

View File

@ -141,9 +141,13 @@ function play(player){
if(xhr.status == 200) {
addLog('message send to bot ' + player + ':' + stringToSend);
addLog('his awnser is: ' + xhr.responseTEXT);
var reponse = eval(xhr.responseTEXT);
try{
var reponse = JSON.parse(xhr.responseTEXT);
var cellTarget= reponse['play'];
}catch(e){
addLog('player ' + player + ' a fait une réponse non conforme aux specs: ' + xhr.responseTEXT);
return;
}
//test format of response
var reg = '/^[0-2]\-[0-2]$/';