Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3636086
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:59:09+00:00 2026-05-19T00:59:09+00:00

I have a single page that I need to on occasion asynchronously check the

  • 0

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();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:59:09+00:00Added an answer on May 19, 2026 at 12:59 am

    Use the cache option of $.ajax() to append a cache breaker to the URL, like this:

    $.ajax({
        type: 'get',
        url: '/live/live.php',
        dataType: 'json',
        cache: false,
        //success, etc.
    });
    

    If that doesn’t resolve it…look at firebug, see if a request is being made (it should be after this for sure), if it’s still getting an old value, the issue is in PHP, not JavaScript.


    Unrelated to the issue, just a side tip: If you need no parameters, you can skip the anonymous function call, this:

    setTimeout(function() { checkLive() } ,15000);
    

    can just be:

    setTimeout(checkLive, 15000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have A single page that has the following structure <form runat=server><placeholder></placeholder></form> I have
Basically I have a single page site that scrolls when the user clicks on
Basically I have a single page on my site that I want any php
In my current Contrete5 project, I have a single page, that takes one url
I have many single-page PDF files that need to be merged into one with
I have a single page website that changes content based on variables passed through
I have an application where every single page uses a set of data that
I have an image upload page (single page). When submitted it check filesize and
I currently have a single asp.net page that displays a grid with a single
I have a single page with with 3 different groups of FAQ's. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.