Reputation: 93
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
Reputation:
function databaseCall() {
// do something;
}
setInterval(databaseCall, 30000);
will execute databaseCall() every 30000 milliseconds, 30 seconds
-edit- thank you stecb
Upvotes: 3
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