indexphp
view plaincopy to clipboardprint?
<mce:script type="text/javascript"><!
var xmlHttp;
function createXMLHttpRequest(){
if(windowActiveXObject){
xmlHttp = new ActiveXObject("MicrosoftXMLHTTP");
}
else if(windowXMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function start(){
createXMLHttpRequest();
var url="getTimephp";
xmlHttpopen("GET"urltrue);
xmlHttponreadystatechange = callback;
xmlHttpsend(null);
}
function callback(){
if(xmlHttpreadyState == ){
if(xmlHttpstatus == ){
documentgetElementById("showtime")innerHTML = xmlHttpresponseText;
setTimeout("start()");
}
}
}
// ></mce:script>
<html>
<head>
<meta httpequiv="contenttype" content="text/html;charset=gb" />
</head>
<body>
<h>Ajax动态显示时间</h>
<input type="button" value="开始显示时间" id="go" onclick="start()" />
<p>当前时间<font color="red"><span id="showtime"></span></font></p>
</body>
</html>
<mce:script type="text/javascript"><!
var xmlHttp;
function createXMLHttpRequest(){
if(windowActiveXObject){
xmlHttp = new ActiveXObject("MicrosoftXMLHTTP");
}
else if(windowXMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
function start(){
createXMLHttpRequest();
var url="getTimephp";
xmlHttpopen("GET"urltrue);
xmlHttponreadystatechange = callback;
xmlHttpsend(null);
}
function callback(){
if(xmlHttpreadyState == ){
if(xmlHttpstatus == ){
documentgetElementById("showtime")innerHTML = xmlHttpresponseText;
setTimeout("start()");
}
}
}
// ></mce:script>
<html>
<head>
<meta httpequiv="contenttype" content="text/html;charset=gb" />
</head>
<body>
<h>Ajax动态显示时间</h>
<input type="button" value="开始显示时间" id="go" onclick="start()" />
<p>当前时间<font color="red"><span id="showtime"></span></font></p>
</body>
</html>
getTimephp
view plaincopy to clipboardprint?
<?php
header("cachecontrol:nocachemustrevalidate");
header("ContentType:text/html;charset=gb");
$showtime = date("北京时间Y年m月d日H:i:s");
echo $showtime;
?>