<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Dynamic Display Time-www.cxybl.com</title>
<script language= "JavaScript" >
var xmlHttp;
function Createxmlhttprequest () {
if (window. ActiveXObject) {
XmlHttp = new ActiveXObject ("Microsoft". XMLHTTP ");
}
else if (window. XMLHttpRequest) {
XmlHttp = new XMLHttpRequest ();
}
else{
Alert ("Create request Failed");
}
}
function SendRequest () {
Createxmlhttprequest ();
url = "time_check.php";
Xmlhttp.onreadystatechange = callback;
Xmlhttp.open (' Get ', url,true);
Xmlhttp.send (NULL);
}
function callback () {
if (Xmlhttp.readystate ==4) {
if (Xmlhttp.status = = 200) {
document.getElementById ("Time"). InnerHTML = Xmlhttp.responsetext;
SetTimeout ("SendRequest ()", 1000);
}
}
}
</script>
<body>
<input type= "button" value= "Check It" onclick= "sendrequest ();"/>
<br/>
<span id= "Time" ></span>
</body>
Server-side code:
Copy code code as follows:
<?php
Header ("Cache-control:no-cache,must-revalidate"); To cancel the settings for the PHP page cache
Header (' content-type:text/html;charset=gb2312 ');
$showtime = Date ("H:i:s y-year m-month D-Day");
Echo $showtime;
?>