Search Results

Search found 1 results on 1 pages for 'michaelespinosa'.

Page 1/1 | 1 

  • Basic Ajax Cache Issue

    - by michaelespinosa
    I have a single page that I need to on occasion asynchronously check the server to see if the status of the page is current (basically, Live or Offline). You will see I have a function with a var live that is set when the page initially loads. I then do an ajax request to the server to retrieve whether the status of live is true or false. I compare the initial live variable with the newly returned data json object. If they're the same I do nothing, but if there different I apply some css classes. I recursively run it with setTimeout (Is there a better way to recursively do this?). My Problem: data.live doesn't change from it's initial time it runs even when it has changed in the db. I know my mysql is working because it returs the right value on the initial load. It seems like a caching issue. Any help is greatly appreciated. function checkLive() { var live = <?=$result["live"]?>; $.ajax({ type: 'get', url: '/live/live.php', dataType: 'json', success: function(data) { console.log('checking for updates... current:' + data.live); if (data.live == live) { return; } else { var elems = $('div.player_meta, object, h3.offline_message'); if (data.live == '1') { elems.removeClass('offline').addClass('live'); } else { elems.addClass('live').addClass('offline'); } } } }); setTimeout(function() { checkLive() } ,15000); } checkLive();

    Read the article

1