把下面的代码修复一下改成每3秒获取一次updatephp文件并提交h6centerp当前在线:span id=slzxrsphp echo slzxrs; span 人_ 累计观看人数:span id=sxcsphp echo sxcs; span 人pcenterh6scriptsetIntervalfunction var xmlhttp = new XMLHttpRequest;
<h6><center><p>当前在线:<span id="slzxrs"><?php echo slzxrs(); ?></span> 人_ 累计观看人数:<span id="sxcs"><?php echo sxcs(); ?></span> 人</p></center></h6>
<script>
setInterval(function(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
document.getElementById("slzxrs").innerHTML = this.responseText;
}
};
xmlhttp.open("GET", "update.php", true);
xmlhttp.send();
var xmlhttp2 = new XMLHttpRequest();
xmlhttp2.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
document.getElementById("sxcs").innerHTML = this.responseText;
}
};
xmlhttp2.open("GET", "update.php", true);
xmlhttp2.send();
}, 3000); // 每3秒获取一次
</script>
原文地址: https://www.cveoy.top/t/topic/b8hO 著作权归作者所有。请勿转载和采集!