简体   繁体   中英

Refresh PHP include()

What is the best way to refresh the content of a var that is included? For example, I have this code:

<marquee>
     <?php
          include('note.php');
     ?>
</marquee>

This is great, as I can show on the page the contents of note.php . Say I change note.php but I don't want users refreshing to see the changes...is there any way to refresh the included file every 3 minutes for example?

To refresh only a portion of a page, you'll have to use some kind of Ajax Request : once the page has been sent to the browser, the server has done it's job, and cannot modify is anymore : the request of fetching a new portion of the page as to come from the browser.

You could do some Ajax requesting "by hand", it's not that hard ; but I'd rather suggest that you take a look at some of the great javascript frameworks that exists out there -- that might be helpful in the future, when adding more functionnalities to your application.

For instance :

只有通过使用ajax之类的调用..看一下原型或jquery来获得不错的JS库来帮助解决这个问题。

Unless you just want to put some javascript in to refresh the page every three minutes, you'll need to look into another technology, namely AJAX. As far as I know, PHP can not do this alone.

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