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 7605801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:15:30+00:00 2026-05-31T00:15:30+00:00

I want my page to check if a PHP file returns ‘true’ every few

  • 0

I want my page to check if a PHP file returns ‘true’ every few seconds, and refresh a certain div if the PHP file has returned ‘true’. Currently I have this, which isn’t working and is for the complete page instead of the div (I’d like the div to refresh only instead of the complete page):

<script type="text/javascript">
$(document).ready(function(){
    setInterval("checkTime()", 10000);
    function checkTime(){
        $.ajax({
            url: 'checktime.php',
            success: function(refresh){
                if(refresh == "true"){
                    location.reload(true);
                }   
            }
        });
    }

});
</script>

EDIT:

Following the instructions given here I placed the following code in my header:

  $(document).ready(function(){        
    function checkTime(){
        $.ajax({
            dataType: 'json',
            url: 'checktime.php',
            success: function(data){
                if(data.refresh == "true"){
                    $('#tv').load('tv.php');
                }   
            }
        });
    }
    setInterval(function() {checkTime()}, 10000);
});

My TV div looks like this:

<div id="tv">
<? include 'tv.php' ?>
</div>

When I manually go to checktime.php and refresh my index, the tv div is updated properly at the correct time. However nothing seems to happen from the javascript in the header.

  • 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-31T00:15:31+00:00Added an answer on May 31, 2026 at 12:15 am

    You will need a url to send the div html when it needs the refresh. Following will load contsent from that url into the div you specify. I added a trim to the refresh text in case server sends and extraneous spaces or line breaks

    Uses jQuery AJAX shortcut method load()

    http://api.jquery.com/load/

    $(document).ready(function(){
        setInterval("checkTime()", 10000);
        function checkTime(){
            $.ajax({
                url: 'checktime.php',
                success: function(refresh){
                    if($.trim(refresh) == "true"){
                        $('#myDivID').load(refreshDivUrl)
                    }   
                }
            });
        }
    
    });
    

    EDIT: there is actually a simpler logic for this. Send back “false” for no refresh, otherwise send back the html and save an extra call to get the new html

    $(document).ready(function(){
        setInterval("checkTime()", 10000);
        function checkTime(){
            $.ajax({
                url: 'checktime.php',
                success: function(refresh){
                    if($.trim(refresh) != "false"){
                        $('#myDivID').html(refresh)
                    }   
                }
            });
        }
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to check whether or not a cookie is set with every page
i just uploaded my php file to my new server, i want to check
Currently I have a file called hits.php and on any page I want to
I want to check if a particular page gets redirected or not. However, whenever
i want to check remote url's page contents. IF remote site's page content contains
I want to check if my users are fans of my facebook page. I
I want to check password strength of password entered by user in Asp.Net page.
i have a signup page and i want to check username exists or not
hey every one I newbie in php and i make simple upload page and
I want to make a page of php that run automatically on decided time

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.