The $.ajax has two returns: success and error.
If $.ajax calls a php module, how to dispatch the responses to success and to error ?
For example:
if this line of code returns an error:
$connection = mysql_connect($server,$user,$password);
I would like to receive the error in ajax-error
if the execution of the php module is correct then I would like to receive a message in ajax-sucess
If I send echo “message” from PHP I receive the message always in ajax-success and I am obliged to test what is a success and what is not !
From the jQuery ajax documentation:
On server-side the request has already succeed. Normally the resulting callback will be the success handler, not the error handler.
You should handle the mysql_connect error in the ajax-success handler.