I’m experimenting with JSON and http response codes. I’m submitting a form via an AJAX request and I obviously need to validate the data on the server-side.
My idea is to respond with a “200 OK” response (with a confirmation message as the body) if the post is successful. I don’t know what to respond with if the data that the user sends is invalid.
Just implement a standard protocol like JSON-RPC. It has error handling, parameter passing, etc.
Request:
Response:
And on error:
It’s quite flexible, and is standard…