刷新PHP页面,每predefined秒 [英] Refresh a PHP page for every predefined seconds

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

问题描述

我想加载/刷新某个特定页面,每10秒,查看从数据库中更新数据的获取。

我用META做它

 < META HTTP-EQUIV =刷新内容= '10; URL = livedata.php'>
 

  

不过,我同意,我们也这样做   使用:

     
      
  • JavaScript来加载一个div通过setTimeout的
  •   
  • 在阿贾克斯动态刷新
  •   

如果您共享使用META的性能问题将是巨大的,AJAX动态刷新,使用Javascript的setTimeout ..也分享这样做的最好方法。

请注意:无需刷新整个页面,而不是特定的帧或DIV

解决方案

使用AJAX是最少intruisive给用户,因为用户没有注意到的东西是被刷新/重装直至完成

请注意,AJAX可以根据不同的情况进行比META更好或更差:

  • 如果数据需要更新的小,对于完整的HTML页面大小,AJAX比META越好,因为随着AJAX可以只发送数据的差异,以及/或者您也可以发送比HTML更紧凑的格式的数据
  • 在运行JavaScript的把包袱给用户的浏览器。如果用户有20个选项卡中打开(这是不常见),他们每个人在后台运行一些setTimeout的,它可以使浏览器respoinsiveness的巨大差异把所有他们给JavaScript无刷新。

I would like to load/refresh a particular page for every 10 secs to view updated data's fetched from Database.

I used META for doing it

 <META HTTP-EQUIV=Refresh CONTENT='10; URL=livedata.php'>

But still i agree we also do this by using :

  • Javascript to load a div by settimeout
  • Ajax dynamic refresh

Would be great if you share the performance issues using META , AJAX dynamic refreshing , Javascript settimeout .. Also share the best way of doing it.

Note : Need to refresh whole page rather than specific frame or div.

解决方案

Using AJAX is the least intruisive to the user, because the user doesn't notice that something is being refreshed/reloaded until it is complete.

Please note that AJAX can perform better or worse than META depending on the situation:

  • If the data to be updated is small with respect to the full HTML page size, AJAX is better than META, because with AJAX you can send only the data difference, and/or you can send data in more compact format than HTML.
  • Running JavaScript puts a burden to the user's browser. If the user has 20 tabs open (which is not uncommon), and each of them runs some setTimeout in the background, it can make a huge difference in browser respoinsiveness to convert all of them to JavaScript-free refresh.

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

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