用activexobject或xmlhttprequest对象读服务器上的XML文件怎么读不到?那里有问题?
var http;
function createhttp()
{
if(window.ActiveXObject)
{
http = new window.ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
http = new XMLHttpRequest();
}
}
function execut()
{
createhttp();
http.onreadystatechange = fan();
http.open("POST",XMLFile.xml,true);
http.send(null);
}
function fan()
{
if(http.readyState == 4)
{
if(http.status == 200)
{
var doc = http.responseXML;
var data = doc.getElementByTagName("Data")[0].firstChild.nodeValue;
var node = document.getElementById("d");
node.innerHTML = "<b>"+data+"</b>";
}
}
}
XML文件
<?xml version="1.0" encoding="utf-8" ?>
<XMLHTTP>
<Data>
Hi!
</Data>
</XMLHTTP>
------解决方案--------------------
少了s,写js时ie里的脚本错误调试要记得开着
var data = doc.getElementsByTagName("Data")[0].firstChild.nodeValue;