readyState

Xmlhttp object reference
XMLHttpRequest object XMLHttpRequest member onreadystatechange readyState ResponseBody responsestream responseText responsexml status statustext about getallresponseheaders getresponseheader open send setrequestheader readyState
Returns the current status of the xmlhttp request
grammar
lValue = oXMLHttpRequest.readyState;
Example
Var XmlHttp;
XmlHttp = new ActiveXObject(“Msxml2.XMLHTTP.3.0”);
function send() {
XmlHttp.onreadystatechange = doHttpReadyStateChange;
XmlHttp.open(“GET”, “http://localhost/sample.xml”, true);
XmlHttp.send();
}
function doHttpReadyStateChange() {
if (XmlHttp.readyState == 4) {
alert(“Done”);
}
}
Remarks
Variable. This property is read-only. The status is represented by an integer with a length of 4. The definition is as follows:
0 (uninitialized) object established but not initialized (open method not called)
1 (initialization) object established, send method not called
2 (send data) send method called, but the current status and HTTP header are unknown
3 (in data transmission) part of the data has been received. Because the response and HTTP header are incomplete, there will be an error in obtaining part of the data through ResponseBody and responseText,
4 (completion) after receiving the data, you can obtain the complete response data through ResponseBody and responseText
Reference resources
Open method
ResponseBody property
ResponseText property
Send method
Status attribute
Statustext property

发布了133 篇原创文章 · 获赞 191 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/blog_programb/article/details/105616910