Specifies the event handler to be invoked when the readyState property changes.
Visual Basic Syntax
oXMLHttpRequest.onreadystatechange = funcMyHandler
C/C++ Syntax
HRESULT put_onreadystatechange(
VARIANT readystatechangeSink);
Parameters
readystatechangeSink
[in]
Name of the function that should be called when the readystate property value changes.
C/C++ Return Value
Returns S_OK if successful, or an error code otherwise.
Remarks
This event has the same syntax as the IXMLDOMDocument onreadystatechange event.
You can call the IXMLHttpRequest object's QueryInterface method to obtain the IConnectionPointContainer interface, which is used in event management.
Example
The following example specifies the handler HandleStateChange gets called when an XMLHTTP object's readyState property changes. A button on a page is enabled when readyState indicates that all data has been received (readystate = = 4):
<script>
var xmlhttp=null;
function PostOrder(xmldoc)
{
varxmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("POST", "http://myserver/orders/processorder.asp", false);
xmlhttp.onreadystatechange= HandleStateChange;
xmlhttp.Send(xmldoc);
myButton.disabled = true;
}
function HandleStateChange()
{
if (xmlhttp.readyState == 4)
{
myButton.disabled = false;
alert("Result = " + xmlhttp.responseXML.xml);
}
}
</script>
In Visual Basic, you can get a function pointer using the syntax getRef("HandleStateChange").
C/C++ Example