I have this snipped of code for my database connection
$res = odbc_exec($connection, $sql);
if (!$res) {
$arr = array('a' => 1);
header('Content-type: application/json');
echo json_encode($arr);
}
in my java script i have
......
...
success: function(data) {
if (data.a == 1){
$('#myidselector').html("<div><p>Somethign went wrong</p></div>");
}
},
.....
.....
....
now i am aware that there is error function for ajax but once when php code goes to line
odbc_exec($connection, $sql);
it spits out the error and execution stops and never gets to java script . All I want to do is handle database error gracefully. Does anyone have suggestions how to handle this.