HOW DO YOU SET INTERVAL TO AJAX CALL IN JQUERY

C G E Mannerheim

Total Post:29

Points:203
Posted by  C G E Mannerheim
 3556  View(s)
Ratings:
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() {
    .
    .
    .
    }
});
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: how do you set interval to ajax call in jquery

    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
    });

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!