onreadystatechange
指定当readyState属性改变时的事件处理句柄
语法
oXMLHttpRequest.onreadystatechange = funcMyHandler;
Example
如下的例子演示当XMLHTTPRequest对象的readyState属性改变时调用HandleStateChange函数,当数据接收完毕后(readystate == 4)此页面上的一个按钮将被激活
var xmlhttp=null; function PostOrder(xmldoc) { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.5.0"); 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); } }