简体   繁体   English

使用JavaScript / PHP每5秒刷新一次DIV

[英]Refresh DIV only every 5 seconds with JavaScript/PHP

I have been googling about this issue for my messaging system with PHP and MySQL. 我一直在谷歌搜索有关PHP和MySQL的消息系统的这个问题。 I cannot work out how to refresh just the div that contains the messages so it can be updated every five seconds without using jquery or AJAX. 我无法弄清楚如何刷新包含消息的div,因此可以每五秒更新一次,而无需使用jquery或AJAX。 I don't want to use these because I want the website to be compatible with pretty much anything (ie phone, tablet, computer even e-reader browser). 我不想使用这些,因为我希望网站几乎兼容任何东西(即手机,平板电脑,电脑甚至电子阅读器浏览器)。

Is it possible to do this with HTML, PHP or JavaScript, and if so, how? 是否可以使用HTML,PHP或JavaScript执行此操作,如果是,如何执行此操作?

I guess you are using php to get content from back end. 我猜你使用php从后端获取内容。 You can use $('#idOfdiv').load("somePHPscriptToUpdateDiv.php") inside setTimeOut(function(){},5000) 你可以$('#idOfdiv').load("somePHPscriptToUpdateDiv.php") setTimeOut(function(){},5000)使用$('#idOfdiv').load("somePHPscriptToUpdateDiv.php") setTimeOut(function(){},5000)

You can use an iframe with reloading to a url to a PHP page to get that effect without AJAX. 你可以使用iframe重新加载到PHP页面的url,以便在没有AJAX的情况下获得该效果。 I don't think iframe is more supported than AJAX, though. 不过,我认为iframe不比AJAX更受支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM