Home >Web Front-end >HTML Tutorial >Understanding http status code 204_html/css_WEB-ITnose
There are many types of HTTP status codes, mainly 1xx (temporary response), 2xx (success), 3xx (redirected), 4xx (request error) and 5xx (server error). Major categories, each major category also corresponds to some specific classifications. Usually we have more contact with 200, 400, 500, etc.
Here we mainly discuss status code 204. The description of 204 in HTTP RFC 2616 is as follows:
If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view.
means that the request is executed successfully, but there is no data. The browser does not need to refresh the page, nor does it need to be directed to a new page . How to understand this passage? Let's illustrate it through an example. Suppose there is a form on the page and the submitted URL is http-204.htm. When you submit the form, under normal circumstances, the page will jump to http-204.htm, but if http-204.htm The corresponding status code is 204. At this time, the page will not jump and will still stay on the current page. In addition, for the a tag, if the linked page response code is 204, the page will not jump.
So for some data submitted to the server for processing, if you only need to return whether it is successful, you can consider using status code 204 as the return information, thereby eliminating redundant data transmission.