码迷,mamicode.com
首页 > Web开发 > 详细

jquery ajax 显示服务器时钟

时间:2015-06-22 07:32:17      阅读:173      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!