Skip to main content
onreadystatechange Property

Sets or retrieves the event handler for asynchronous requests.


[ vHandler = ] object.onreadystatechange [ = v ]

Possible Values

vHandlerVariant that specifies or receives the event handler.

The property is read/write. The property has no default value.


onreadystatechange was introduced in Windows Internet Explorer 7.


The following script demonstrates how to set an event handler that responds to asynchronous events:

function reportStatus()
    if (oReq.readyState == 4)
        alert('Transfer complete.');

var oReq = new XMLHttpRequest();
oReq.onreadystatechange = reportStatus;"GET", "http://localhost/test.xml", true);

Standards Information

This property is defined in The XMLHttpRequest Object (W3C Working Draft)  World Wide Web link.

Applies To

XMLHttpRequest, XMLHttpRequest Constructor

See Also