Home > DeveloperSection > Forums > how do you set interval to ajax call in jquery
C G E Mannerheim
C G E Mannerheim

Total Post:29

Points:203
Posted on    July-08-2013 8:18 AM

 JavaScript JavaScript 
Ratings:


 1 Reply(s)
 2794  View(s)
Rate this:
Hi Developers!

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


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    July-08-2013 8:29 AM

Hi,

try this

$.ajax({
url: "test.html",
error: function(){
    // will fire when timeout is reached
},
success: function(){
    //do something
},
timeout: 3000 // sets timeout to 3 seconds
});

Don't want to miss updates? Please click the below button!

Follow MindStick