aWebDeveloper
aWebDeveloper

Reputation: 38432

How should an AJAX endpoint signal that servicing the request has failed?

What data do I need to send from my server (PHP) so that jQuery recognizes it as error and executes the error callback?

Upvotes: 1

Views: 77

Answers (2)

Arthur Halma
Arthur Halma

Reputation: 4001

<?php
header('HTTP/1.1 500 Internal Server Error');
?>

Upvotes: 2

Mark Costello
Mark Costello

Reputation: 4394

You could send any of the 5xx Server Error codes listed here back in your HTTP header. http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Or else, you could just send back a message that states an error has occurred in the response, then check for that string on the client and handle that...

Upvotes: 0

Related Questions