<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<h1 id="tt"></h1>
</body>
</html>
<script>
function $(id){
return document.getElementById(id);
}
var x=new XMLHttpRequest();
x.onreadystatechange=function(){
if(x.status==200&&x.readyState==4){
//alert(x.responseText);可以直接打印出来
$(‘tt‘).innerHTML = x.responseText;
}
}
function myt(){
x.open(‘GET‘,‘a.php?‘+new Date());
x.send(null);
}
setInterval(myt,1000);
</script>
a.php页面代码
<?php
echo date(‘Y-m-d H:i:s‘);
时间: 2024-10-13 12:25:48