PHP脚本运行太多次

时间:2019-08-08 03:34:00

标签: php html

这是我在index.html中使用的XML代码,该代码调用show_vote.php脚本。 我像这样<script>showVoteResult()</script>在index.html的主体中调用此函数。由于某种原因,在我的cpanel的CPU使用率中,它说一遍又一遍地请求PHP文件,并且超出了CPU使用率的限制。我需要帮助来了解我做错了什么地方。

function showVoteResult() {
  if (window.XMLHttpRequest) {
    // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
  } else { // code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function() {
    if (this.readyState==4 && this.status==200) {
      document.getElementById("currentVote").innerHTML=this.responseText;
    }
  }
  xmlhttp.open("GET","show_vote.php",true);
  xmlhttp.send();
}

0 个答案:

没有答案