25
I have a form that will be submitted to the server via ajax, using a plugin for this. When the form is not filled in correctly (in case when a mandatory parameter is missing), I want to return a JSON with an error message and an error status, so that in javascript, the plugin enters the error callback instead of success.
I know you must be one of the 4xx family, but I don’t know which one.
Doesn’t seem to be any of those:
400 - Bad request: the request worked, so much so that I returned a JSON
404 - Not found: the feature exists, so much that I can give POST to it
403 - Forbidden: I don’t think so either
What is the status I must return?
Here you have all the codes, but I do not think there is an error for this, since there is no requirement for http q to be passed a post. You may want to default to 412. http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
– CCastro
Laravel, PHP framework adopted the
422
by default, when there is any invalid data by request validation. Missing the parameter would be equivalent to violating validationrequired
.– Wallace Maxters