vincent
vincent

Reputation: 93

making a call to the database every 30secs

i am making a database call in javascript with amfphp. I would like to be able to execute the call every 30secs. How would i do that?

Upvotes: 0

Views: 285

Answers (2)

user657496
user657496

Reputation:

function databaseCall() {
    // do something;
}

setInterval(databaseCall, 30000);

will execute databaseCall() every 30000 milliseconds, 30 seconds

-edit- thank you stecb

Upvotes: 3

Thew
Thew

Reputation: 15959

Addition to rsplak's example:

Use jQ AJAX icw PHP

 <script src="http://code.jquery.com/jquery-1.5.js"></script>
 <script>
    function update(){
        $.get('query.php', function(data) {
                $('#return').html(data);
        });
        setTimeout(update, 30000);
    }

    update();
  </script>

Upvotes: 1

Related Questions