
一、直接在<head>区域中添加代码
<meta http-equiv="refresh" content="5">
注意:这里的5,是每5秒刷新一次;相同的代码,如果后面跟有URL地址,则表示5秒以后,自动跳转到新的网址,如<meta http-equiv="refresh" content="5;url="http://lvjin.job.sh">
二、在页面中添加JS代码:
<script language="JavaScript">
function myrefresh(){
window.location.reload();
}
setTimeout('myrefresh()',1000);
</script>
注意:这里的1000,即1000毫秒(1秒),另 window.location.href = window.location.href;可以代替 window.location.reload()使用;function myrefresh(){
window.location.reload();
}
setTimeout('myrefresh()',1000);
</script>
三、局部更新(须引用jquery-1.11.2.js文件,附件可下载),直接上代码了:
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script>
$(function (){
setInterval(function () {
$("#abc").load(location.href + " #abc");
}, 1000);
})
</script>
</head>
<body >
<div id="abc"><?php require_once('djs.php');?></div>
</body>
</html>
注意:href后面要有空格。<html lang="zh-cn">
<head>
<meta charset="utf-8">
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script>
$(function (){
setInterval(function () {
$("#abc").load(location.href + " #abc");
}, 1000);
})
</script>
</head>
<body >
<div id="abc"><?php require_once('djs.php');?></div>
</body>
</html>

参考自:cnblogs
四、Ajax手动版,参考DEMO附件




