关于xmlhttprequest.readystate的一个问题

来源:百度知道 编辑:UC知道 时间:2024/06/28 01:29:21
我用xmlhttprequest向服务器发送了一个请求后

在回调函数中监测xmlhttprequest.readystate,
使用alert(xmlhttprequest.readystate)
点击按钮之后,我发现有时候1,2,3,4都出现 ,
但有时候只有1,就停住了,然后我刷新页面就出现2,4
这是为什么
请高人指点

//come from Ajax hack书
onreadystatechange

Callback function; the function assigned to this property is called whenever readyState changes.

readyState

Number;
0 means uninitialized, open( ) has not yet been called;
1 means loading, send( ) has not been called;
2 means loaded, send( ) has been called, and headers/status are available;
3 means interactive, responseText holds partial data;
4 means completed.

responseText

string; the plain text of the response.

responseXML

DOM Document object; an XML return value.

status

Response status code, such as 200 (Okay) or 404 (Not Found).

statusText

string; the text associated with the HTTP response status.

The methods supported include:

abort( )

void; cancels the HTTP request.

getAllResponseHeaders( )

string; returns all of the res