Ajax status value and status code in the advanced Ajax tutorial

Source: Internet
Author: User
Tags ajax status code
1-differences between Ajax Status values and Status Codes

The Ajax status value refers to several States that have been used to run Ajax. no matter whether the access is successful or not, the response steps can be understood as Ajax running steps. For example, sending and responding are obtained when the Ajax object interacts with the server. You can use "Ajax. readystate" to obtain the result. (From numbers 1 ~ Composed of 4 numbers)

Ajax status code indicates the HTTP header information code returned by the server based on the information submitted by the HTTP protocol, regardless of whether Ajax access is successful or not. status (consisting of numbers 1xx and 2XX. For details, see RFC)

This is why we use the following method to determine whether the obtained information is correct when using Ajax.

If (Ajax. readystate = 4 & Ajax. Status = 200 ){

Putdata (Ajax. responsetext );

}

2-Ajax running steps and Status values

In actual Ajax running, the access to XMLHttpRequest (xhr) is not completed at one time, but the results obtained after multiple States, for which there are five statuses in Ajax, yes.

0-(not initialized) The send () method has not been called

1-(load) The send () method has been called and a request is being sent.

2-(Load completed) The send () method is executed completely,

3-(interaction) parse the response content

4-(complete) The response content has been parsed and can be called on the client

For the above status, "0" is the status value automatically generated after the definition, and for the successful access status (get information) We mostly use "4" for judgment.

Note: We still remember the conditions for processing functions in the callback function when using native Ajax.

Xhr. onreadystatechange = function (){

If (xhr. readystate = 4 & xhr. Status = 200 ){

// Service Processing of the callback function

}

}

Xhr. readystate is the status value of Ajax.


3-Ajax Status Code Description (Status Code)

 

1 **: request received, continue processing

2 **: The operation is successfully received, analyzed, and accepted.

3 **: the request must be further processed.

4 **: The request contains an error syntax or cannot be completed

5 **: the server failed to execute a fully valid request.

100 -- the customer must continue to send the request

101 -- the client requests the server to convert the HTTP protocol version according to the request

200 -- transaction successful

201 -- prompt to know the URL of the new file

202 -- accept and process, but not complete

203 -- the returned information is uncertain or incomplete

204 -- the request is received, but the returned information is null.

205 -- when the server completes the request, the user agent must reset the file that has been browsed.

206 -- the server has completed some users' GET requests

300 -- the requested resources can be obtained in multiple places

301 -- Delete request data

302 -- request data found at other addresses

303 -- we recommend that you access other URLs or access methods.

304 -- the client has executed get, but the file has not changed

305 -- the requested resource must be obtained from the address specified by the server

306 -- code used in HTTP of the previous version, which is not used in the current version

307 -- declaring temporary deletion of requested resources

400 -- incorrect request, such as syntax error

401 -- authorization request failed

402 -- retain valid chargeto header response

403 -- the request is not allowed

404 -- no file, query, or URL found

405 -- the method defined in the request-line field is not allowed.

406 -- the requested resource is inaccessible due to the user's accept drag.

407 -- similar to 401, the user must first be authorized on the Proxy Server

408 -- the client did not complete the request within the specified time

409 -- the request cannot be completed due to the current resource status

410 -- this resource is no longer available on the server and there is no further reference address

411 -- the server rejects the User-Defined Content-Length attribute request

412 -- one or more request header fields are incorrect in the current request

413 -- the requested resource is larger than the size allowed by the server

414 -- the requested resource URL is longer than the length allowed by the server

415 -- the requested resource does not support the format of the requested project

416 -- The request contains the range request header field. There is no range indication value in the current request resource range, and the request does not contain the IF-range request header field.

417 -- the server does not meet the expectation specified in the header field of the response CT request. If it is a proxy server, it may be that the next-level server cannot meet the request

500 -- Internal error occurred on the server

501 -- the server does not support the requested function

502 -- the server is temporarily unavailable, sometimes to prevent system overload

503 -- server overload or service suspension

504 -- the gateway is overloaded. The server uses another gateway or service to respond to the user. The waiting time is long.

505 -- the server does not support or reject the specified HTTP version in the Request Header

 

4-Ajax running steps

Related Article

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.