林创建仪表板的大屏幕显示器在工作中,我设法得到一个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"));
});