AJAX的jQuery DIV刷新每5秒 [英] AJAX jQuery refresh div every 5 seconds

查看:642
本文介绍了AJAX的jQuery DIV刷新每5秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从一个网站,我已经修改了我的需要这个code:

I got this code from a website which I have modified to my needs:

<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>

在test.php的:

In test.php:

<?php echo 'test'; ?>

所以我想test.php的被称为每5秒中的链接股利。我该怎么做吧?

So I want test.php to be called every 5 seconds in links div. How can I do this right?

推荐答案

尝试了这一点。

function loadlink(){
    $('#links').load('test.php',function () {
         $(this).unwrap();
    });
}

loadlink(); // This will run on page load
setInterval(function(){
    loadlink() // this will run after every 5 seconds
}, 5000);

希望这有助于。

Hope this helps.

这篇关于AJAX的jQuery DIV刷新每5秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆