jquery auto refresh without blinking

Ivo picture Ivo · Nov 10, 2012 · Viewed 89.2k times · Source
<script type="text/javascript">
window.onload = setupRefresh;

function setupRefresh() {
  setTimeout("refreshPage();", 1000);
}
function refreshPage() {
   window.location = location.href;
}

The page is now reloading every second the only problem its blinking how to fix this

Answer

Robbert Grobben picture Robbert Grobben · Nov 10, 2012

You could use a div and a .get with jquery to get your data from another page on your website.

You can use setTimeOut(function, time)

$(function() {
    startRefresh();
});

function startRefresh() {
    setTimeout(startRefresh,1000);
    $.get('pagelink.php', function(data) {
        $('#content_div_id').html(data);    
    });
}