stribor40 Posted August 16, 2013 Share Posted August 16, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/281258-catching-database-error-with-ajax/ Share on other sites More sharing options...
requinix Posted August 16, 2013 Share Posted August 16, 2013 it spits out the error and execution stops and never gets to java script .Are you sure? The documentation for odbc_exec() says nothing about errors or exceptions - just that the function returns false. Quote Link to comment https://forums.phpfreaks.com/topic/281258-catching-database-error-with-ajax/#findComment-1445440 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.