HTTP 204 and 205 applications

Source: Internet
Author: User
Tags header http 200 reset

The HTTP 204 (no content) indicates a successful response, but no data is returned, and the browser does not need to be refreshed or directed to a new page.

The HTTP 205 (reset content) indicates a successful response, resetting the page (form form) to facilitate the user's next entry.

When using AJAX, you can use the Status code HTTP 204来 instead of HTTP 200 to reduce redundant data transfers when you only need to know the success or failure of the response.

Example: Ajax submit user name, article ID, record user visited the article

$ (document). Ready (function () {  
  $.get ("api.php", {name: ' Fdipzone ', article_id: ');  
})
<?php  
      
$name = $_get[' name '];  
$article _id = $_get[' article_id '];  
      
Do sth  
      
header (' http/1.1 204 No Content ');  
      
? >

HTTP status Code header output:

/** * HTTP Protocol defined status codes * @param int $num/function Httpstatus ($num) {static $ht TP = Array (=> "http/1.1 Continue", => "http/1.1-switching Protocols", 2  
       => "http/1.1 OK", 201 => "http/1.1 201 Created", "=>",  203 => "http/1.1 203 non-authoritative Information", 204 => "http/1.1 204 No Content", 205 => "http/1.1 205 Reset Content", 206 => "http/1.1 206 Partial Content", => "http/1.1 E choices ", =>" http/1.1 moved Permanently ", 302 =>" http/1.1 302 Found ", 303 =&G T  
       "http/1.1 303", 304 => "http/1.1 304 not Modified", 305 => "http/1.1 305 use Proxy", 307 => "http/1.1 307 temporary Redirect", => "http/1.1 bad Request", 401 => "HTTP /1.1 401 Unauthorized", 402 =>" http/1.1 402 Payment Required ", 403 =>" http/1.1 403 forbidden ", 404 =>" HT tp/1.1 404 Not Found ', 405 => ' http/1.1 405 Method not allowed ', 406 => ' http/1.1 406 not Acceptab  
       Le ", 407 =>" http/1.1 407 Proxy Authentication Required ", 408 =>" http/1.1 408 Request time-out ", 409 => "http/1.1 409 Conflict", 410 => "http/1.1 410 Gone", 411 => "http/1.1 411 lengt H Required ", 412 =>" http/1.1 412 precondition Failed ", 413 =>" http/1.1 413 Request Entity Too La  
       Rge ", 414 =>" http/1.1 414 request-uri Too Large ", 415 =>" http/1.1 415 unsupported Media Type ",  
       416 => "http/1.1 416 requested range not satisfiable", 417 => "http/1.1 417, expectation Failed", => "http/1.1 Internal Server Error", 501 => "http/1.1 501 Not implemented", 502 =&G T "http/1.1 502 Bad GateWAY ", 503 =>" http/1.1 503 Service Unavailable ", 504 =>" http/1.1 504 Gateway Time-out "  
         
   );  
Header ($http [$num]); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.