小编use*_*972的帖子

AJAX jQuery刷新div每5秒

我从一个网站获得了这个代码,我根据自己的需要进行了修改:

<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>
Run Code Online (Sandbox Code Playgroud)

在test.php中:

<?php echo 'test'; ?>
Run Code Online (Sandbox Code Playgroud)

所以我希望在链接div中每隔5秒调用一次test.php.我怎么能这样做?

javascript php ajax jquery

24
推荐指数
3
解决办法
16万
查看次数

标签 统计

ajax ×1

javascript ×1

jquery ×1

php ×1