javascript在load(.xml)时加载出错 javascriptxmlload()dreamveaver网页前端 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 xmlDoc=document.implementation.createDocument('', '', null);xmlDoc.async=falsealert("即将加载文件"+xmlDoc); xmlDoc.load('canshu.xml'); 因为你异步加载,导致还未加载xml文件完毕就执行到console.log("根节点标签"+xmlDoc.firstChild.tagName)这句了 参考: XML Parser这样是不是更兼容?function loadXmlDoc(){ var zhishuArray=new Array(); var xmlDoc; alert("进入loadXmlDoc"); if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.status==200) { xmlDoc=xmlhttp.responseXML; alert("加载文件之后"+xmlDoc); console.log("根节点标签"+xmlDoc.firstChild.tagName); alert("根节点标签"+xmlDoc.firstChild.tagName); getmessage(); } else { alert('加载失败,状态码: '+xmlhttp.status); } } alert("即将加载文件"+xmlDoc); xmlhttp.open("GET","canshu.xml",false); xmlhttp.send();} jquery中的函数问题 jquery怎样给自己写的插件中的函数传参并得到结果 有没有人遇到过这个问题? 简单的JS代码问题求解! showModelessDialog有几个问题,最小化,唯一化,父框关闭子框 请问能否模拟出ctrl+F执行的查找操作? 求拆分合并表格单元格的函数,并把拆分合并后的表格源码记录下来 怎样在文本框中移动光标? 我是初学者,请帮帮忙.先谢了. 如何修改访问的一个网址的内部链接的HTTP头信息 js调用百度地图API,由于异步执行导致结果顺序不对以及数据丢失 JS返回上一级页面, 显示用户名
xmlDoc.async=false
alert("即将加载文件"+xmlDoc);
xmlDoc.load('canshu.xml');
因为你异步加载,导致还未加载xml文件完毕就执行到console.log("根节点标签"+xmlDoc.firstChild.tagName)这句了
这样是不是更兼容?function loadXmlDoc(){
var zhishuArray=new Array();
var xmlDoc;
alert("进入loadXmlDoc");
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.status==200)
{
xmlDoc=xmlhttp.responseXML;
alert("加载文件之后"+xmlDoc);
console.log("根节点标签"+xmlDoc.firstChild.tagName);
alert("根节点标签"+xmlDoc.firstChild.tagName);
getmessage();
}
else
{
alert('加载失败,状态码: '+xmlhttp.status);
}
}
alert("即将加载文件"+xmlDoc);
xmlhttp.open("GET","canshu.xml",false);
xmlhttp.send();
}