我似乎无法找到问题所在。当我在Xampp中运行它时它工作正常,但是当我将它转移到hostgator时它不起作用它在控制台中说
未捕获的TypeError:无法读取null的属性'getElementsByTagName'
这是代码:
function LoadAsOwner()
{
Filename = document.getElementById('filename').value;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET",Filename, false);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
LAO(xmlhttp);
}
};
xmlhttp.send();
}
function LAO(xml)
{
var x="", i="", xmlDoc="", txt="",i="";
xmlDoc = xml.responseXML;
x = xmlDoc.getElementsByTagName("question");
Qlength=x.length;
QCset=new Array(Qlength);
for(i=0;i<x.length;i++)
{
QCset[i]={
Answer: x[i].getElementsByTagName("term")[0].childNodes[0].nodeValue
,Question: x[i].getElementsByTagName("detail")[0].childNodes[0].nodeValue
,Selected: 0
};
}
selectQuestions();
}