AbtPst
AbtPst

Reputation: 8018

How to trigger the reload button in jQGrid at set time intervals

I want my grid to periodically reload and get the data from the url that i specify. Every 5 seconds, i want the grid to get the current data from the url. I have already tried using setInterval and window.timeout but when i do, the grid reloads the data from the browser cache. It does not invoke the url to get the new data.

Is there a way to make the grid reload and get the new data from the url at specific time intervals ?

Basically, i want the reload button to fire automatically every 5 seconds. How can I do this ?

please help

thanks

Upvotes: 0

Views: 624

Answers (2)

AbtPst
AbtPst

Reputation: 8018

Thanks,

I figured out a way:

    window.setTimeout( refreshGrid, 8000);
    function refreshGrid()
    {
    jQuery("#refresh_list").click();
window.setTimeout(refreshGrid, 8000);

     }

Upvotes: 0

EZLearner
EZLearner

Reputation: 1834

What you need, is to use the same method you've been using before, but to prevent the browser's cache. One method of doing so, is on the server-side, add a no-cache header to to the HTTP response for that request.

Another way of doing so, is to change the request's URL, so the browser won't look it up its cache. One example is:

var url = "..."; // Your URL
url += "&nocache=" + (new Date()).getTime();

Upvotes: 1

Related Questions