开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜