user580523
user580523

Reputation:

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 file every 10 seconds?

Any help would be great,

Thanks!

Upvotes: 0

Views: 5227

Answers (2)

MacMac
MacMac

Reputation: 35361

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.

Upvotes: 0

genesis
genesis

Reputation: 50982

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

Upvotes: 3

Related Questions