2

I need to create an ajax call every 5 minutes. I have to below code. Can someone tell me how would I modify this code to run that ajax every 5 minutes?

    $(document).ready(function() {
     var seriesOptions = [],
        yAxisOptions = [],
        colors = Highcharts.getOptions().colors;


        $.ajax({
                    url: 'echo_file.php', 
                    datatype: 'json',
                    success: function(data) {

                        seriesOptions=data;
                        createChart();
                    },

                    cache: false    
                    });

       function createChart() {
    .
    .
    .
    }
});
user1471980
  • 10,127
  • 48
  • 136
  • 235
  • Put it into a setInterval, or even better, turn it into a function that calls itself after 5 minutes. – Kevin B Jul 08 '13 at 14:56

1 Answers1

27

At the simplest level, put your AJAX call into a function, then create an interval:

setInterval(ajaxCall, 300000); //300000 MS == 5 minutes

function ajaxCall() {
    //do your AJAX stuff here
}
tymeJV
  • 103,943
  • 14
  • 161
  • 157