Search code examples
phpjavascriptautorepeat

autorepeat a php script


i would like to ask how can i make a php script which echoes the id of the data stored in a database repeat itself after specific time for example after 2 minutes.i don't want to use a cron job or another scheduler.Just php or javascript implemantation.Thanks in advance..


Solution

  • I've done similar with this script. While the user is on the page, it runs scriptToRun.php every 2 minutes.

    function changeFeedAddress() {
        $.ajax({
            type: 'get',
                url: 'scriptToRun.php',
                success: function(txt) {
                    // do something with the new RSS feed ID here
                }
            });
        }
    
    setInterval(changeFeedAddress,120000); //   2 MINUTES