Fuxi
Fuxi

Reputation: 7599

How to trap PHP errors so they can be sent back in an AJAX response?

I'm using $.post for grabbing XML content from an external PHP script and I'm wondering - if that scripts raises a PHP error - how can I trap it in order to send it back inside my XML response?

I've tried implementing some PHP error trapping into that server-side-script like this:

$rc = set_error_handler("myErrorHandler");

Unfortunately it doesn't work. it still raises PHP errors the normal way.

Any ideas what could be wrong?

Upvotes: 1

Views: 183

Answers (1)

Amy Anuszewski
Amy Anuszewski

Reputation: 1853

I generally check the response to the ajax request for error strings and then handle them on the Javascript side.

Upvotes: 2

Related Questions