php+ajax实现页面自动刷新时间
2009-07-26 22:37
811 查看
index.php
getTime.php
<mce:script type="text/javascript"><!-- var xmlHttp; function createXMLHttpRequest(){ if(window.ActiveXObject){ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest){ xmlHttp = new XMLHttpRequest(); } } function start(){ createXMLHttpRequest(); var url="getTime.php"; xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange = callback; xmlHttp.send(null); } function callback(){ if(xmlHttp.readyState == 4){ if(xmlHttp.status == 200){ document.getElementById("showtime").innerHTML = xmlHttp.responseText; setTimeout("start()",1000); } } } // --></mce:script> <html> <head> <meta http-equiv="content-type" content="text/html;charset=gb2312" /> </head> <body> <h1>Ajax动态显示时间</h1> <input type="button" value="开始显示时间" id="go" onclick="start()" /> <p>当前时间:<font color="red"><span id="showtime"></span></font></p> </body> </html>
getTime.php
<?php header("cache-control:no-cache,must-revalidate"); header("Content-Type:text/html;charset=gb2312"); $showtime = date("北京时间Y年m月d日H:i:s"); echo $showtime; ?>
相关文章推荐
- 黄聪:PHP如何实现延迟一定时间后自动刷新当前页面、自动跳转header("refresh:1;url={$url}");
- 如何用php+ajax实现页面的局部刷新?(转)
- php+ajax 实现web页面无闪烁刷新 页面前端和后端交互
- Ajax+php实现自动刷新页面
- php自动刷新与关闭页面后继续执行,定时任务的实现方式
- 用gulp-livereload实现自动刷新页面(v3.0.2)
- 网站页面自动跳转实现方法PHP、JSP(下)
- js返回上一页,自动刷新自身、父页面语句的实现
- 详解Grunt插件之LiveReload实现页面自动刷新(两种方案)
- php+ajax实现无刷新数据分页的办法
- php+JQuery+Ajax简单实现页面异步刷新 (转)
- asp.net使用javascript实现不刷新页面获取当前时间
- 自动刷新页面的实现方法总结
- js实现html页面显示时间的定时刷新
- 解析PHP计算页面执行时间的实现代码
- 网站页面自动跳转实现方法PHP、JSP等
- [转载]Grunt插件之LiveReload 实现页面自动刷新,所见即所得编辑
- PHP+Ajax实现无刷新分页实例详解(附demo源码下载)
- php+ajax 前台页面获取标准网络时间
- 利用js实现对页面的自动刷新