jQuery PHP Refresh Content
I'm looking for a way of refreshing a PHP include using jQuery.
I had a go but needed to re-include the database config file which isn't what I wanted.
Is there a nice easy way of including and auto refreshing a fil开发者_StackOverflow社区e every 10 seconds?
Any help would be great,
Thanks!
There are no "PHP includes"
However you can poll for new entries into your element every 10 seconds by using this code
$(function(){
setInterval(function(){
$("#your_element").load("new_entries.php");
}, 10 * 1000);
});
where "new_entries.php" gives you fresh news from your database
This will repeat every 10 seconds using the load
function that will display the contents in an element.
function refreshConfig()
{
setTimeout(function()
{
$('#element').load('database_config.php', function()
{
refreshConfig();
});
}, 10000);
}
If you need something different, please explain more better.
精彩评论