我有一个功能,我想每秒刷新一次数据库。 div会刷新,但不会从页面中接收内容。
这是我的rightmenutimer.php
<?
include "includes/db_connect.php";
$username=$_SESSION["real_name"];
$sql="SELECT * from bankers WHERE name='$username'";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){ // Start looping table row
$time = time();
$timeleft= $rows['gtatime'];
$last = $timeleft - $time;
$timeleft2=righttime($timeleft);
?>
<?if ($timeleft < "$time"){echo"<font color=green>Available</font>";}else{echo"<b>$timeleft2</b>";}?><?}?>
这是我的函数/ html:
<script type="text/javascript">
function Ajax(){
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest();// Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("No AJAX!?");
return false;
}
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById('ReloadThis').innerHTML=xmlHttp.responseText;
setTimeout('Ajax()',1000);
}
}
xmlHttp.open("GET","rightmenutimers.php",true);
xmlHttp.send(null);
}
window.onload=function(){
setTimeout('Ajax()',1000);
}
</script>
<tr><td width="100%">
<table border="1" width="100%" bgcolor="222222">
<tr>
<td width="35%" bgcolor="#171717">GTA</td>
<td width=65%><div id="ReloadThis"><b><a href="_steal_car"><? if ($timeleft < "$time"){?><font color=green>Available</font><?}else{echo"<b>$timeleft2</b>";}?></a></div></td>
</tr>
</table>
</td></tr>
任何人都可以告诉我为什么这不会显示,提前谢谢