PHP - Create error status for return in ajax

Asked

Viewed 129 times

0

To perform a system validation I need to create an error status and get this status in ajax in:

error: (function (erro) {
    //codigo 
})

Based on http_response_code(404); of PHP.

I can make a mistake 603 and get this mistake 603 on the return of the ajax ?

I tried to change/include the status 603 in http_response_code("603"); but on the return of the ajax, I obtained the code 500

  • What is the need for the specific error? The existing codes do not solve it?

  • The need is for internal system handling. For example, adding a debtor, without adding a contract, generates error. And for each error, there is a specific message to be displayed.

  • http://php.net/manual/en/function.http-response-code.php#114996

  • I’ve read about it, but haven’t found how I can include an error status

  • This is exactly what it says on the link, any code that is not an error of the indicated list, will be changed to a standard answer (200 or 500). Maybe use the function header directly. http://php.net/manual/en/function.http-response-code.php#107261

  • That’s right!

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.