What is a http status code?

An HTTP status code is the three-digit number at the start of every server response that says whether the request worked and, if not, why.

The first digit gives the class. Codes from 200 to 299 mean success, 300 to 399 mean a redirect to another address, 400 to 499 mean the request was wrong in some way, and 500 to 599 mean the server failed. Common ones are 200 OK, 303 See Other, 400 Bad Request, 404 Not Found, 429 Too Many Requests and 500 Internal Server Error.

When a form is sent with JavaScript, the status code is how your code knows what happened. A script that shows "Thanks!" without checking the status will thank visitors whose message was rejected.

FormTango answers a stored submission with 200 and a JSON result, or with a 303 redirect for a plain form post. It uses 400 when the form had no named fields or the body could not be read, 403 for a paused form, 404 for an unknown form id, 413 for a submission that is too large, 415 for an unsupported content type and 429 for too many submissions.

http
HTTP/1.1 200 OK
Content-Type: application/json

{ "ok": true, "id": "..." }

Related