我收到错误:未捕获TypeError:无法读取属性' documentElement'为null 使用此代码:
function respondHandler() {
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
xmlResponse = xmlHttp.responseXML;
xmlDocumentElement = xmlResponse.documentElement;
message = xmlDocumentElement.firstChild.data;
document.getElementById('output').innerHTML = message;
}else{
alert('something went really wrong');
}
}
}
它首先奏效了,现在它已经开始了。我真的不知道出了什么问题!
答案 0 :(得分:0)
人
function respondHandler() {
// get element reference here
var element = document.getElementById('output');
if(xmlHttp.readyState == 4){
if(xmlHttp.status == 200){
xmlResponse = xmlHttp.responseXML;
xmlDocumentElement = xmlResponse.documentElement;
message = xmlDocumentElement.firstChild.data;
element.innerHTML = message;
}else{
alert('something went really wrong');
}
}