简体   繁体   English

TypeError:document.getElementById(…)为空GetAsyncOnline

[英]TypeError: document.getElementById(…) is null GetAsyncOnline

I get a TypeError: document.getElementById(...) is null but cant find the solution... 我收到一个TypeError:document.getElementById(...)为null但找不到解决方案...

Uncaught TypeError: Cannot set property 'innerHTML' of null GotAsyncOnline 未捕获的TypeError:无法设置null GotAsyncOnline的属性'innerHTML'

this error occor in firefox and chrome Firefox和Chrome中出现此错误

This is the script: 这是脚本:

<script language=javascript type="text/javascript">
<!-- Hide script from non-JavaScript browsers

var req_online;

// GetAsyncOnline sends a request to read the status.
function GetAsyncOnline() {
url = "../../../../../../ivr/consulenten-overzicht.php";

// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
  req_online = new XMLHttpRequest();
  req_online.abort();
  req_online.onreadystatechange = GotAsyncOnline;
  req_online.open("POST", url, true);
  req_online.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');

  req_online.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
  req_online = new ActiveXObject("Microsoft.XMLHTTP");
  if (req_online) {
    req_online.abort();
    req_online.onreadystatechange = GotAsyncOnline;
    req_online.open("POST", url, true);
    req_online.send();
  }
}
}

// GotAsyncStatus is the read callback for the above XMLHttpRequest() call.
// This routine is not executed until data arrives from the request.
// We update the "fifo_data" area on the page when data does arrive.
function GotAsyncOnline() {
// only if req_online shows "loaded"
if (req_online.readyState != 4 || req_online.status != 200) {
  return;
 }
document.getElementById("status_online").innerHTML=
  req_online.responseText;

// Schedule next call to wait for fifo data
setTimeout("GetAsyncOnline()", 40000);
return;
}

-->

<body onLoad="GetAsyncOnline()">

yes i forgot this part, 是的,我忘记了这一部分,

this comes below the body: 这是在身体下面:

<table width="100%" border="0" cellspacing="2" cellpadding="4">
<tr>
<td valign="top">   
<div id="status_online">
<center>
<img src="images/loading.gif"><br>
<b><font color="#8791e2" size="2" face="Arial, Helvetica, sans-serif">Laden van Consulenten</font></b>
</center>
</div></td>
  </tr>

</tr>
</table>

Following the error it must be in this line: document.getElementById("status_online").innerHTML= req_online.responseText; 错误发生后,它必须在此行中:document.getElementById(“ status_online”)。innerHTML = req_online.responseText;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM