I'm using jquery's ajax function to send json to a php script and return a json set of values for front end processing.
The php script is sending the json and I am able to echo out the json from the php script and retrieve via the success function parameter.
My question is how should I be handling errors. Is there a preferred way to send exception information (validation, etc.) back to the front end, and indicate that an error has occurred in php. Should I just be packaging up such information in a json object and checking what was received.
Thanks,
$.ajax({
url: 'gear.php',
type: 'POST',
data: {'json': JSON.stringify(shopping)},
success: function(data){
console.info(data);
},
error: function(data){
console.info(data);
}
});