When I send an Ajax request in JavaScript (with JQuery), it sometimes throws an internal server error that I can’t catch. The error shows up in the browser. I even tried to wrap the ajax call in a try – catch block. How can I handle the Ajax error?
EDIT
here is my code:
$.post('/multi/getGameStatus', function(data) {
if(data && data.game) {
settings.game = data.game;
setStartRacePopupUI.call(this, data);
// remove all racers
removePlayers.call();
for(var i=0;i<settings.game.players.length;i++) {
var player = settings.game.players[i];
var isme = (player.id == settings.playerId);
addPlayer.call(this, player, isme, i);
}
if (settings.game.gameStatus == "OPEN") {
setTimeout(refreshPlayers, refreshPlayersInterval, nextStatus);
} else if(settings.game.gameStatus == "IN_GAME") {
counterToGameStart = data.sts;
gameFllow(nextStatus);
}
}
});
Even if I use the error handler I still get a JS error on the page
http://api.jquery.com/jQuery.ajax/