当我的计时器计数为00:00:00 alert('Get Result')按钮或提交表单时
我什至不能在response.php中发出警报消息。
这是我从数据库中选择持续时间的地方
while($row=mysqli_fetch_array($res))
{
$duration=$row["duration"];
}
$_SESSION["duration"]=$duration;
$_SESSION["start_time"]=date("Y-m-d H:i:s");
$end_time=$end_time=date('Y-m-d H:i:s', strtotime('+'.$_SESSION["duration"].'minutes',strtotime($_SESSION["start_time"])));
$_SESSION["end_time"]=$end_time;
这是response.php
<?php
session_start();
$from_time1=date('Y-m-d H:i:s');
$to_time1=$_SESSION["end_time"];
$timefirst=strtotime($from_time1);
$timesecond=strtotime($to_time1);
$differenceinseconds=$timesecond-$timefirst;
if($differenceinseconds<0){
// This is for when timer smaller then 0 then = 00:00:00
$differenceinseconds=0;
echo "TIME UP<br>";
//I try to alert a simple message here, and dint work. Why is this happen
}
echo gmdate("H:i:s",$differenceinseconds);
?>
这是测验页面中的javascript
<script type="text/javascript">
var x =setInterval(test,1000);
function test()
{
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","response.php",false);
xmlhttp.send(null);
document.getElementById("response").innerHTML=xmlhttp.responseText;
}
</script>
显示计时器标签
<div id=response class=timer style=font-size:30px></div>
表单名称和按钮
<form name=myfm method=post action=quizz.php>
<input type=submit name=submit value='Get Result'>
慕姐8265434
相关分类