verif JSON format
This commit is contained in:
parent
ca56fab131
commit
b0f5e6a36e
|
@ -141,9 +141,13 @@ function play(player){
|
||||||
if(xhr.status == 200) {
|
if(xhr.status == 200) {
|
||||||
addLog('message send to bot ' + player + ':' + stringToSend);
|
addLog('message send to bot ' + player + ':' + stringToSend);
|
||||||
addLog('his awnser is: ' + xhr.responseTEXT);
|
addLog('his awnser is: ' + xhr.responseTEXT);
|
||||||
|
try{
|
||||||
var reponse = eval(xhr.responseTEXT);
|
var reponse = JSON.parse(xhr.responseTEXT);
|
||||||
var cellTarget= reponse['play'];
|
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
|
//test format of response
|
||||||
var reg = '/^[0-2]\-[0-2]$/';
|
var reg = '/^[0-2]\-[0-2]$/';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user