使用AJAX更新中心窗格。未捕获类型错误:无法设置属性';innerHTML';空值(重复2次)
非常感谢您的回复。我用以下代码更新了代码。我正在使用DojoDataGrid来呈现数据。这对我来说仍然不起作用。然而 这是代码。Google debugger显示了一个“未捕获的TypeError:无法将属性'innerHTML'设置为null(重复2次)。“这一行后面的错误”element.innerHTML=xhr.responseText使用AJAX更新中心窗格。未捕获类型错误:无法设置属性';innerHTML';空值(重复2次),ajax,Ajax,非常感谢您的回复。我用以下代码更新了代码。我正在使用DojoDataGrid来呈现数据。这对我来说仍然不起作用。然而 这是代码。Google debugger显示了一个“未捕获的TypeError:无法将属性'innerHTML'设置为null(重复2次)。“这一行后面的错误”element.innerHTML=xhr.responseText 在调用setHtml之前,请添加console.log(dojo.byId('centerPane'))检查元素是否存在。我已经准备好了这个问题。非常感
在调用setHtml之前,请添加
console.log(dojo.byId('centerPane'))
检查元素是否存在。我已经准备好了这个问题。非常感谢!
function UpdateCenterPane(dest) {
var setHtml = function(element, url) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
element.innerHTML = xhr.responseText;
}
};
xhr.timeout = 10000;
xhr.open('GET', url, true);
xhr.send();
};
setHtml(dojo.byId('centerPane'),dest);
}
I set up breakpoints to step through the code. I found this if block of code was skipped. xhr.readyState returns 0 and xhr.status=0.