Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用AJAX更新中心窗格。未捕获类型错误:无法设置属性';innerHTML';空值(重复2次)_Ajax - Fatal编程技术网

使用AJAX更新中心窗格。未捕获类型错误:无法设置属性';innerHTML';空值(重复2次)

使用AJAX更新中心窗格。未捕获类型错误:无法设置属性';innerHTML';空值(重复2次),ajax,Ajax,非常感谢您的回复。我用以下代码更新了代码。我正在使用DojoDataGrid来呈现数据。这对我来说仍然不起作用。然而 这是代码。Google debugger显示了一个“未捕获的TypeError:无法将属性'innerHTML'设置为null(重复2次)。“这一行后面的错误”element.innerHTML=xhr.responseText 在调用setHtml之前,请添加console.log(dojo.byId('centerPane'))检查元素是否存在。我已经准备好了这个问题。非常感

非常感谢您的回复。我用以下代码更新了代码。我正在使用DojoDataGrid来呈现数据。这对我来说仍然不起作用。然而

这是代码。Google debugger显示了一个“未捕获的TypeError:无法将属性'innerHTML'设置为null(重复2次)。“这一行后面的错误”element.innerHTML=xhr.responseText


在调用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.