AJAX jQuery 刷新 div 每 5 秒
2022-08-30 15:31:50
我从一个网站得到了这个代码,我已经根据我的需求进行了修改:
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
</head>
<div id="links">
</div>
<script language="javascript" type="text/javascript">
var timeout = setTimeout(reloadChat, 5000);
function reloadChat () {
$('#links').load('test.php #links',function () {
$(this).unwrap();
timeout = setTimeout(reloadChat, 5000);
});
}
</script>
测试中.php:
<?php echo 'test'; ?>
因此,我希望在链接div中每5秒调用一次测试.php。我怎样才能做到这一点?