Is there a clean, easy way to throw php exceptions through a json response jquery/ajax call.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could do something like this in PHP (assuming this gets called via AJAX):
In JavaScript:
You can also trigger the
error:handler of $.ajax() by returning a 400 (for example) header:Or use
Status:if you’re on FastCGI. Note that theerror:handler doesn’t receive the error details; to accomplish that you have to override how$.ajax()works 🙂