readyState Property (IXMLHTTPRequest)

 

Represents the state of the request.

Script Syntax

lValue = oXMLHttpRequest.readyState;  

Example

var XmlHttp;
XmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");

function send() {
   XmlHttp.onreadystatechange = doHttpReadyStateChange;
   XmlHttp.open("GET", "https://localhost/sample.xml", true);
   XmlHttp.send();
}

function doHttpReadyStateChange() {
   if (XmlHttp.readyState == 4) {
      WScript.Echo("Done");
   }
}

Visual Basic Syntax

lValue = oXMLHttpRequest.readyState  

C/C++ Syntax

HRESULT get_readyState(long* plState);  

Parameters

plState [out, retval]
State of the request, as an I4 (4-byte integer). See Remarks for information about supported values.

C/C++ Return Values

S_OK
Value returned if successful.

Remarks

Variant. The property is read-only. It represents the state of the request as an I4 (4-byte integer). The following values are defined.

0 (UNINITIALIZED) The object has been created, but not initialized (the open method has not been called).
(1) LOADING The object has been created, but the send method has not been called.
(2) LOADED The send method has been called, but the status and headers are not yet available.
(3) INTERACTIVE Some data has been received. Calling the responseBody and responseText properties at this state to obtain partial results will return an error, because status and response headers are not fully available.
(4) COMPLETED All the data has been received, and the complete data is available in the responseBody and responseText properties.

This property returns a 4-byte integer.

Note

In MSXML 3.0 and MSXML 6.0, reading the status property after loading has commenced but has not yet completed (for example, at the LOADED or INTERACTIVE state) returns the following error: "The data necessary to complete this operation is not yet available."

Versioning

Implemented in:

MSXML 3.0, MSXML 6.0

Applies to

IXMLHTTPRequest

See Also

open Method (IXMLHTTPRequest)
responseBody Property (IXMLHTTPRequest)
responseText Property (IXMLHTTPRequest)
send Method (IXMLHTTPRequest)
status Property (IXMLHTTPRequest)
statusText Property (IXMLHTTPRequest)