Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How does the current state of xmlhttprequest change?


Asked by Kristopher Melendez on Dec 15, 2021 FAQ



XMLHttpRequest changes between states as it progresses. The current state is accessible as xhr.readyState. An XMLHttpRequest object travels them in the order 0 → 1 → 2 → 3 → … → 3 → 4. State 3 repeats every time a data packet is received over the network.
Also,
The readyState property holds the status of the XMLHttpRequest. The onreadystatechange property defines a function to be executed when the readyState changes. The status property and the statusText property holds the status of the XMLHttpRequest object.
Besides, The readyState property defines the current state of the XMLHttpRequest object. The following table provides a list of the possible values for the readyState property − The request is not initialized. The request has been set up. The request has been sent. The request is in process. The request is completed.
In this manner,
To send an HTTP request, create an XMLHttpRequest object, open a URL, and send the request. After the transaction completes, the object will contain useful information such as the response body and the HTTP status of the result.
Accordingly,
The onreadystatechange property defines a function to be executed when the readyState changes. The status property and the statusText property holds the status of the XMLHttpRequest object. The onreadystatechange function is called every time the readyState changes. When readyState is 4 and status is 200, the response is ready: