What is meaning of xhr.readystate===4

后端 未结 2 682
挽巷
挽巷 2021-02-01 00:46

Is it right to say that the AJAX call has completed after xhr.readystate===4?
Here it says the state is complete. So what does th

2条回答
  •  温柔的废话
    2021-02-01 01:11

    An Ajax http request has 5 states as your reference documents:

    0   UNSENT  open() has not been called yet.
    1   OPENED  send() has been called.
    2   HEADERS_RECEIVED    send() has been called, and headers and status are available.
    3   LOADING Downloading; responseText holds partial data.
    4   DONE    The operation is complete.
    

    State 4 means that the request had been sent, the server had finished returning the response and the browser had finished downloading the response content. So, it is right to say that the AJAX call has completed.

提交回复
热议问题