首页 > Web开发 > 详细

jquery ajax 显示服务器时钟

时间:2015-06-22 07:30:53      阅读:293      评论:0      收藏:0      [点我收藏+]
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>无标题文档</title>
  6. </head>
  7. <body>
  8. <h1 id="tt"></h1>
  9. </body>
  10. </html>
  11. <script>
  12. function $(id){
  13. return document.getElementById(id);
  14. }
  15. var x=new XMLHttpRequest();
  16. x.onreadystatechange=function(){
  17. if(x.status==200&&x.readyState==4){
  18. //alert(x.responseText);可以直接打印出来
  19. $(‘tt‘).innerHTML = x.responseText;
  20. }
  21. }
  22. function myt(){
  23. x.open(‘GET‘,‘a.php?‘+new Date());
  24. x.send(null);
  25. }
  26. setInterval(myt,1000);
  27. </script>
a.php页面代码
  1. <?php
  2. echo date(‘Y-m-d H:i:s‘);






jquery ajax 显示服务器时钟

原文:http://www.cnblogs.com/lsr111/p/4592773.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!