自动刷新多的div使用jQuery [英] Auto refresh multiple divs with Jquery

查看:83
本文介绍了自动刷新多的div使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林创建仪表板的大屏幕显示器在工作中,我设法得到一个DIV自动刷新一个PHP请求的页面,但我想不出用在另一个分区的另一个脚本此功能的方法不复制全功能和重命名它,这似乎只是愚蠢的。

这是我到目前为止有:

 <脚本类型=文/ JavaScript的>
$(文件)。就绪(
功能更新()
{
    $获得(response.php功能(数据){
            $(#ajaxtest)的HTML(数据);
            window.setTimeout(更新,10000);
        });
});
< / SCRIPT>
 

我这样做的计算器一些搜索,发现这个漂亮的小物,虽然其单格只使用...(的第二个例子:使用jQuery 自动刷新的div)

解决方案

  $(文件)。就绪(

功能更新(EL)
{
    $获得(response.php功能(数据){
    el.html(数据);
    window.setTimeout(EL,10000);
});

更新($(#ajaxtest));

});
 

Im creating a dashboard for a large display at work, I have managed to get one div auto refreshing a php request page, but I can't think of a way of using this function on another div for another script without copying the entire function and renaming it, which just seems dumb.

This is what I have so far:

<script type="text/JavaScript"> 
$(document).ready(
function update() 
{
    $.get("response.php", function(data){
            $("#ajaxtest").html(data);
            window.setTimeout(update, 10000);
        });
});
</script>

I did so some searching on stackoverflow and found this nifty little extract, although its for single div use only... (second example: auto refreshing div with jquery)

解决方案

$(document).ready(

function update(el) 
{
    $.get("response.php", function(data){
    el.html(data);
    window.setTimeout(el, 10000);
});

update($("#ajaxtest"));

});

这篇关于自动刷新多的div使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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