开发者

making a call to the database every 30secs

开发者 https://www.devze.com 2023-02-19 18:29 出处:网络
i am making a database call in javascript with amfphp. I would like to be able to execute the call every 30secs. How would 开发者_JS百科i do that?function databaseCall() {

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


function databaseCall() {
    // do something;
}

setInterval(databaseCall, 30000);

will execute databaseCall() every 30000 milliseconds, 30 seconds

-edit- thank you stecb


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>
0

精彩评论

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