Surendra Singh Surendra Singh - 5 months ago 13
Javascript Question

What is meaning of xhr.readystate===4

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 this
complete
mean?

Answer

A http request in Ajax term has 5 states as your reference document:

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 mean that the request has been sent and server finish returning the response and browser has finished download the response content. So, it is right to say that AJAX call has completed.