0

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!

1
  • 3
    AJAX allows you to make HTTP requests to your web server from within the browser without leaving the page. It cannot interact with PHP in any other way. There are no "PHP includes" when talking about client side programming, only HTTP requests and responses. Your question is too poorly specified to provide any further guidance. Commented Jul 30, 2011 at 0:43

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

3 Comments

I could figure it out. The OP, on the other hand... Just call me Magic Eight Ball... ;)
@JaredFarrish: yep I know OP may not know what and why and ... but he just wanted jquery code to poll php every ten seconds, I do not mind about the rest ;)
"re-include the database config file which isn't what I wanted" makes me suspicious.
0

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.

Comments