js reduce try catch

This commit is contained in:
gnieark 2015-12-17 22:28:51 +01:00
parent c4fa2974cf
commit 828765d840

View File

@ -87,7 +87,7 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi
//alert(xhr.responseText); //alert(xhr.responseText);
try{ try{
var grids = JSON.parse(xhr.responseText); var grids = JSON.parse(xhr.responseText);
catch(e){ }catch(e){
document.getElementById('logs').innerHTML = xhr.responseText; document.getElementById('logs').innerHTML = xhr.responseText;
return; return;
} }
@ -108,7 +108,6 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi
} }
}
}}; }};
xhr.open("POST", '/Battleship', true); xhr.open("POST", '/Battleship', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");