XMLHTTP's readystate and status parameters detailed

Source: Internet
Author: User
Tags response code

In Ajax, there is a check in the status code,

Xmlhttp.onreadystatechange=handlestatechange;

function Handlestatechange ()
{
if (xmlhttp.readystate==4)
{
if (xmlhttp.status==200)
{
Parseresults (); Resolve return value
}
}
}

What do you mean by readyState and status?

XMLHTTP readyState Value Meaning: 0-uninitialized, that is, open has not been invoked. 1-Initialize, that is, send has not been invoked. 2-Send the data, that is, send is already called. 3-in data transfer. 4-Complete.

HTTP Server Status Code definition

1.1 Message 1xx (informational 1xx)

The class status code is used to represent a temporary response. A temporary response consists of a status line (Status-line) and an optional caption, terminated by a blank line. No 1xx status codes are defined in the http/1.0, so they are not legitimate responses to http/1.0 requests. In fact, they are mainly used for experimental purposes, which is beyond the scope of this document.

1.2 Success 2xx (successful 2xx)

Indicates that the client request was successfully received, understood, and accepted.

OK

The request was successful. The information in response depends on the method used by the request, as follows:

The resource you want to request is already in the responding entity.

The head has no entity body, and only the header information is included in the response.

POST Entity (describes or contains the results of the operation).

201 Created

The request completes, resulting in the creation of a new resource. The URI of the newly created resource can be obtained in the responding entity. The original server should create the resource before the status code is issued. If the operation cannot be completed immediately, the server must be prompted in the response body when the resource is available, or the server side should respond to 202 (acceptable).

In the method defined in this article, only post can create a resource.

Accepted

The request was accepted, but processing has not been completed. The request may not necessarily be finalized, and the process may be interrupted at any time, in which case there is no way to resend the status code in an asynchronous operation.

202 back should be without obligation, the purpose of this is to allow the server to respond to requests from other processes (such as a batch-based process, which runs once a day) without waiting for the connection between the user agent and the server to end.

The entities returned in some responses include the status indication for the current request, the status monitor pointer, or the evaluation information that the user can implement for the request.

204 No Content

The server side has implemented the request, but no new information has been returned. If the customer is a user agent, do not need to update their own document view for this. This response is intended to input and otherwise manipulate the script statement without affecting the user agent's view of the document. The response may also include a new, entity-title representation of meta information that can be used by the current user agent to activate a document in the view.

1.3 Redirect (redirection 3xx)

This class status code indicates that the user agent needs to issue further action if it wants to complete the request. These actions can be implemented by the user agent only if the request followed is a GET or head, without interacting with the user. The user agent will never have to do more than 5 redirects to the request, which can result in an infinite loop.

Multiple choices

This status code is not used directly by http/1.0 applications, but as a default interpretation of the 3xx type response. There are multiple available requested resources.

Unless it is a head request, the responding entity must include the character characters and location information of these resources, and the user or user agent determines which is the most appropriate.

If the server has preferred, it should store the corresponding URL information in the location domain (Location field) where the user agent will implement automatic redirection based on the value of the domain.

Permanently moved

The requested resource is assigned a permanent URL so that the resource can be accessed in the future through the URL. Clients that have the Edit Link feature automatically update the request URI as much as possible based on new links that are returned by the server side. The new URL must be specified by the Location field in the response. Unless it is a head request, the entity body (entity-body) of the response must include a brief description of the new URL hyperlink.

If a request is made with the Post method, a 301 response status code is received. In this case, the user agent does not have to automatically redirect the request unless the user confirms it, as this will result in a change to the environment in which the request was made.

Note: When a POST request is automatically redirected after receiving a 301 status code, some existing user agents mistakenly change it to a GET request.

302 Moved temporarily

The requested resource is temporarily saved at a different URL. Because redirects are sometimes changed, the client should continue to use the request URI to issue subsequent requests. The new URL must be specified by the Location field in the response. Unless it is a head request, the entity body (entity-body) of the response must include a brief description of the new URL hyperlink.

If a request is made with the Post method, a 302 response status code is received. In this case, the user agent does not have to automatically redirect the request unless the user confirms it, as this will result in a change to the environment in which the request was made.

Note: When a POST request is automatically redirected after receiving a 302 status code, some existing user agents mistakenly change it to a GET request.

304 Not Modified

If the client successfully executes a conditional GET request and the corresponding file has not been updated since the date specified by the If-modified-since domain, the server should respond to this status code instead of sending the entity principal to the client. The response header field should include only relevant information, such as cache manager, changes unrelated to the recent entity update (entity ' s last-modified) date. Examples of related header fields are: date, server, expiration time. Whenever the value of the field given in the 304 response changes, the cache should update the cached entity.

1.4 Clients error (client error) 4xx

The status code for the 4xx class indicates an error occurred on the client. If the client does not complete the request when it receives 4xx code, it should immediately terminate sending data to the server. In addition to responding to the head request, regardless of whether the error is temporary or permanent, the server side must include an explanation of the error status in the responding entity. These status codes apply to any request method.

Note: If the client is sending data, the TCP implementation on the server side should be careful to ensure that the client receives a response packet before shutting down the input connection. If the client still sends data to the server after it is shut down, the server sends a reset packet to the client, emptying the input buffer that the client has not yet processed to terminate the HTTP application's read and interpret activity.

400 illegal requests (Bad request)

If the requested syntax is not correct, the server will not understand. The client should not repeatedly send the request to the server until it makes a change to the request.

401 not authorized (unauthorized)

The request requires user authorization. The Www-authenticate header field (section 10.16) in the response should prompt the user to request resources in an authoritative manner. The client should repeat the request using the appropriate Authorization header domain (Section 10.2). If the authorization trust information is already included in the request, 401 of the response indicates that the authorization was denied. If the user agent returns a 401 status code after several attempts, the user should look at the responding entity, as there are some related dynamic information included in the entity. HTTP access authorization is explained in section 11.

403 Prohibition (forbidden)

The server understands the request, but refuses to implement the request. Authorization is not helpful, and the client should stop repeatedly sending this request. If you do not use the head request method and the server side is willing to advertise that the request was not implemented, the server will write the reason for the rejection in the response entity. This status code is typically used for server-side details that do not want to advertise requests being rejected or for which no other response is available.

404 Not Found (not Found)

The server did not find a resource that matches the request URI. The 404 status Code does not indicate whether the condition is temporary or permanent. If the server does not want to provide this information to the client, it also responds to the 403 (forbidden) status code.

1.5 Server Error 5XX

A status code that starts with ' 5 ' indicates that the server side finds itself in an error and cannot proceed with the request. If the client has not completed the request when it receives a 5XX status code, it should immediately stop sending data to the server. In addition to responding to the head request, the server should include an explanation of the error condition in its response entity and indicate that it is temporary and permanent.

This type of response code does not have a header field and can be applied to any request method.

500 Server Internal error (Internal server error)

The server encountered an unexpected condition that prevented it from continuing to respond to the request.

501 Not implemented (not implemented)

The server was unable to provide support for the functionality required in the request. If the server does not recognize the request method, it responds to this status code, which means that no resources requested by the request can be answered.

502 Illegal gateways (Bad Gateway)

The server acting as a gateway or proxy receives an illegal response from the upstream (upstream) server where the request is being sent.

503 Service Unavailable (Service unavailable)

The server is currently unable to process the request. This is usually caused by temporary overloading or maintenance of the server. The status code implies that the situation is temporary and that some delay is generated.

Note: The 503 status code does not imply that the server must return this status code when overloaded. Some servers may want to use simple processing when overloading, that is, disconnecting the connection.

Large rollup of IIS error codes

400 cannot resolve this request.

401.1 Unauthorized: Access denied due to invalid credentials.

401.2 Unauthorized: Access was rejected because the server configuration tended to use alternate authentication methods.

401.3 Unauthorized: Access because the ACL's settings for the requested resource are denied.

401.4 Unauthorized: The filter authority installed on the WEB server failed.

401.5 Unauthorized: ISAPI/CGI application authorization failed.

401.7 Unauthorized: Access is denied because of a URL authorization policy on the WEB server.

403 Prohibit access: Access is denied.

403.1 Prohibit access: execution access is denied.

403.2 prevents access: Read access is denied.

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.