简体   繁体   中英

Refresh DIV only every 5 seconds with JavaScript/PHP

I have been googling about this issue for my messaging system with PHP and 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. 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?

I guess you are using php to get content from back end. You can use $('#idOfdiv').load("somePHPscriptToUpdateDiv.php") inside setTimeOut(function(){},5000)

You can use an iframe with reloading to a url to a PHP page to get that effect without AJAX. I don't think iframe is more supported than AJAX, though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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