Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  20] [ 4]  / answers: 1 / hits: 60393  / 11 Years ago, mon, july 8, 2013, 12:00:00

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() {
.
.
.
}
});

More From » jquery

 Answers
59

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
}

[#77130] Saturday, July 6, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
neildrews

Total Points: 166
Total Questions: 103
Total Answers: 85

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
neildrews questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Tue, Oct 12, 21, 00:00, 3 Years ago
Tue, Mar 23, 21, 00:00, 3 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
;