In "Pragmatic Ajax A Web 2.0 Primer"
0: (uninitialized) the Send () method has a not yet been invoked.
1: (Loading) the Send () method has been invoked, request in progress.
2: (Loaded) the Send () method has completed, entire response received.
3: (Interactive) The response is being parsed.
4: (completed) The response has been parsed, was ready for harvesting.
0-(uninitialized) has not yet called the Send () method
1-(load) called the Send () method, sending the request
2-(loading complete) the Send () method executes and has received the full response content
3-(interactive) parsing response content
4-(complete) The response content resolution is complete and can be invoked on the client
1-ajax status value differs from status code
The Ajax state value refers to the several states that run Ajax, which can be interpreted as an Ajax run step, regardless of the steps that will be taken to respond to the success of the access. such as: sending, responding, etc., obtained by the Ajax object interacting with the server; using "Ajax.readystate". (made up of digital 1~4 unit numbers)
The Ajax status code refers to the HTTP header information code returned by the HTTP protocol based on the information submitted, regardless of whether or not the Ajax access was successful, which is obtained using "Ajax.status", which is made up of a digital 1xx,2xx three-bit number, which is detailed in the RfC.
This is why we use Ajax in the following way to determine whether the information obtained is correct.
if (ajax.readystate = = 4 && Ajax.status = =) {PutData (ajax.responsetext);}
|
2-ajax running steps and status value descriptions
In the actual operation of Ajax, the access to XMLHttpRequest (XHR) is not done at once, but the results obtained after a number of different states, for this state in the Ajax there are 5 kinds, respectively.
0-(uninitialized) has not yet called the Send () method
1-(load) called the Send () method, sending the request
2-(loading complete) the Send () method executes,
3-(interactive) parsing response content
4-(complete) The response content resolution is complete and can be invoked on the client
For the above state, where the "0" state is the state value automatically after the definition, and for the status of the successful access (get information) Most of US use "4" to judge.
3-ajax Status Code Description
1**: Request received, continue processing
2**: Successful operation received, analysis, acceptance
3**: Completion of this request must be further processed
4**: request contains an error syntax or cannot be completed
5**: The server failed to perform a fully valid request
100--customer must continue to make a request
101--client requires server to convert HTTP protocol version on request
200--Trading Success
201--prompt to know the URL of the new file
202--accepted and processed, but processing not completed
203--return information is indeterminate or incomplete
204--request received, but return information is empty
205--the server has completed the request, the user agent must reset the files that are currently viewed
206--server has completed a partial user's GET request
300--requested resources can be obtained in multiple places
301--Delete request data
302--found the request data at a different address
303--advising customers to access other URLs or access methods
304--client has performed a get, but the file has not changed
The resource requested by 305--must be obtained from the address specified by the server
306--code used in previous versions of HTTP, no longer used in the current version
307--declaring the requested resource temporary deletion
400--error requests, such as syntax errors
401--Request Authorization failed
402--reserved valid Chargeto header response
403--Request not allowed
404--no files, queries, or URLs found
405--the method defined by the user in the Request-line field does not allow
406--request resource is inaccessible based on accept drag sent by user
407--similar to 401, the user must first be authorized on the proxy server
408--client does not complete the request within the user-specified time of starvation
409--the current resource state, the request cannot be completed
This resource is no longer available on the 410--server and has no further reference address
411--server rejects user-defined Content-length property requests
412--one or more request header fields are incorrect in the current request
413--the requested resource is greater than the size allowed by the server
414--The requested resource URL is longer than the length allowed by the server
415--requesting a resource does not support requesting an item format
The 416--request contains a range request header field that does not have a range indication value within the current request resource scope, and the request does not contain a If-range request header field
The 417--server does not meet the expectations specified by the request Expect header field, and if it is a proxy server, the next level of server may not satisfy the request
500--Server generates internal error
501--server does not support the requested function
502--server is temporarily unavailable, sometimes to prevent system overloads
503--server overload or pause repair
504--Gateway overload, Server uses another gateway or service to respond to users, waiting time setting value is longer
505--server does not support or deny the HTTP version specified in the request header
Ajax status values and status codes