The difference between readyState and status of XMLHttpRequest object

It can be simply understood that state represents the state of a whole . And status is the specific small state under this big state .

For example, the state of water. 

1. Drinkable 

2. Not drinkable 

3.  xxx……

Status of water

1. Minerals

2. Acidic water

3.xxx.....

 

For example, the readyState and status of the XMLHttpRequest object, readyState is 4, there will be a corresponding response status: 500, 404...

readyState represents the processing state of the XMLHttpRequest object:
0: The XMLHttpRequest object has not been initialized. (Prepare the driver, car, and cargo)
1: The XMLHttpRequest object starts sending requests. (Ten trucks of goods need to be delivered, which number is currently being delivered)
2: The request for the XMLHttpRequest object is sent. (Ten trucks have been delivered)
3: The XMLHttpRequest object begins to read the server's response. (Prepare to pull back the ten-car processed goods, the current number of cars)
4: The XMLHttpRequest object reads the server response and ends. (All ten trucks have been pulled back)


status:
1xx: Information response class, indicating that the request is received and processing continues. (All the pulled goods, the factory has not finished processing)  
2xx: Processing success response class, indicating that the action has been successfully received, understood and accepted. . (All the pulled goods factories have been processed)  
3xx: Redirection response class, in order to complete the specified action, it must accept further processing. (All the goods pulled, the factory equipment is not enough, let other factories help to process)  
4xx: Client error, the customer request contains syntax errors or cannot be executed correctly. (These ten trucks have quality problems, and the factory cannot process them normally)

5xx: Server error, the server cannot execute a correct request correctly. (The factory is powered off in the middle of processing and cannot continue processing)


The value and explanation of xmlhttp.readyState:

0: The request is not initialized (open() has not been called).

1: The request has been established, but has not been sent (send() has not been called).

2: The request has been sent and is being processed (usually the content headers can now be obtained from the response).

3: The request is being processed; usually some data is available in the response, but the server has not finished generating the response.

4: The response is complete; you can get and use the server's response.


The value and explanation of xmlhttp.status:

100 - Client must continue making requests

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

200 - successful transaction

201 - Prompt to know the URL of the new file

202 - Accepted and processed, but processing not completed

203 - Return information is uncertain or incomplete

204 - The request was received, but the return information was empty

205 - The server has completed the request, the user agent MUST reset the currently viewed file

206 - The server has completed the GET request of some users

300 - The requested resource is available in multiple places

301 - delete request data

302 - Request data found at other address

303 - Advise customers to visit other URLs or access methods

304 - The client has performed a 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 the previous version of HTTP, no longer used in the current version

307 - Declare the temporary deletion of the requested resource

400 - Bad request, such as syntax error

401——请求授权失败

402——保留有效ChargeTo头响应

403——请求不允许

404——没有发现文件、查询或URl

405——用户在Request-Line字段定义的方法不允许

406——根据用户发送的Accept拖,请求资源不可访问

407——类似401,用户必须首先在代理服务器上得到授权

408——客户端没有在用户指定的饿时间内完成请求

409——对当前资源状态,请求不能完成

410——服务器上不再有此资源且无进一步的参考地址

411——服务器拒绝用户定义的Content-Length属性请求

412——一个或多个请求头字段在当前请求中错误

413——请求的资源大于服务器允许的大小

414——请求的资源URL长于服务器允许的长度

415——请求资源不支持请求项目格式

416——请求中包含Range请求头字段,在当前请求资源范围内没有range指示值,请求也不包含If-Range请求头字段

417——服务器不满足请求Expect头字段指定的期望值,如果是代理服务器,可能是下一级服务器不能满足请求

500——服务器产生内部错误

501——服务器不支持请求的函数

502——服务器暂时不可用,有时是为了防止发生系统过载

503——服务器过载或暂停维修

504——关口过载,服务器使用另一个关口或服务来响应用户,等待时间设定值较长

505——服务器不支持或拒绝支请求头中指定的HTTP版本



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325813973&siteId=291194637