浏览器客户端怎么知道 xml数据 已经下在完毕可以开始操作数据?

findcsdn 2003-10-17 05:32:04
我的脚本操作xml数据的时候,当数据量很大时,总是提示“完成该操作所需数据还不可使用”,不知道怎么解决这个问题。谢谢!
...全文
53 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
awaysrain 2003-10-17
  • 打赏
  • 举报
回复
<script>
var xmldoc;
function Load()
{
xmldoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmldoc.onreadystatechange = CheckState;
xmldoc.load(URL.value);
}
function CheckState()
{
var state = xmldoc.readyState;
RESULTS.innerHTML += "readyState = " + state + "<BR>"
if (state == 4)
{
var err = xmldoc.parseError;
if (err.errorCode != 0)
RESULTS.innerHTML += err.reason + "<BR>"
else RESULTS.innerHTML +="success" + "<BR>"
}
}
<script>
URL: <input type=text size=60 id=URL>
<input type=button value=LOAD onclick="jscript:Load()">
<div id=RESULTS style= "color:red;font-weight:bold;"></div>
nolonely 2003-10-17
  • 打赏
  • 举报
回复
var xmldoc=new ActiveXObject("Microsoft.XMLDOM")
xmldoc.onreadystatechange=check
xmldoc.async=true
xmldoc.load("test.xml")
function check(){
if(xmldoc.readyState==4){
if(xmldoc.xml!="")alert('下载完且可工作')
else alert('XML文件为空')
}
}
77334683 2003-10-17
  • 打赏
  • 举报
回复
学习
rwu 2003-10-17
  • 打赏
  • 举报
回复
如果你是用SRC=1.xml的形式,可以加上一个onload=""标签
awaysrain 2003-10-17
  • 打赏
  • 举报
回复
readyState
===================================

Microsoft XML Core Services (MSXML) 4.0 - DOM Reference

See Also
open Method | responseBody Property | responseText Property | send Method | status Property | statusText Property

Applies to: IXMLHTTPRequest
Language
C/C++

Script

Visual Basic

Show All
readyState Property (IXMLHTTPRequest)
Represents the state of the request.

Example
var XmlHttp;
XmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
XmlHttp.onreadystatechange = doHttpReadyStateChange;
XmlHttp.open("GET", "http://localhost/sample.xml", true);
XmlHttp.send();
function doHttpReadyStateChange() {
if (XmlHttp.readyState == 4) {
alert("Done");
}
}
[Script]
Script Syntax
lValue = oXMLHttpRequest.readyState;
[Visual Basic]
Visual Basic Syntax
lValue = oXMLHttpRequest.readyState
[C/C++]
C/C++ Syntax
HRESULT get_readyState(long* plState);
Parameters
plState [out, retval]
State of the request, as an I4 (4-byte integer). The following values are defined:

(0) UNINITIALIZED The object has been created, but not initialized (open has not been called).
(1) LOADING The object has been created, but send has not been called.
(2) LOADED send has been called and the status and headers are available, but the response is not yet available.
(3) INTERACTIVE Some data has been received. You can call responseBody and responseText to get the current partial results.
(4) COMPLETED All the data has been received, and the complete data is available in responseBody and responseText.


C/C++ Return Values
S_OK
Value returned if successful. Remarks
Variant. The property is read-only. It represents the state of the request as an I4 (4-byte integer). The following values are defined.


0 (UNINITIALIZED) The object has been created, but not initialized (open method has not been called).
(1) LOADING The object has been created, but the send method has not been called.
(2) LOADED The send method has been called and the status and headers are available, but the response is not yet available.
(3) INTERACTIVE Some data has been received. You can call responseBody and responseText to get the current partial results.
(4) COMPLETED All the data has been received, and the complete data is available in responseBody and responseText.


This property returns a 4-byte integer.

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button in the upper-left corner of the page.

See Also
open Method | responseBody Property | responseText Property | send Method | status Property | statusText Property

Applies to: IXMLHTTPRequest
kingdomzhf 2003-10-17
  • 打赏
  • 举报
回复


设置async=false,会同步下载在你执行
var objDoc = new ActiveXObjet("Microsoft.XMLDOM");
objDoc.async = false;
objDoc.load("1.xml");//这个语句后你就可以用dom了

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧