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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:04:13+00:00 2026-05-29T20:04:13+00:00

I have index.php page which makes a ajax call to thread.php by sending the

  • 0

I have index.php page which makes a ajax call to thread.php by sending the variable “dateposted”. The thread.php returns a json which is being looped through in my index.php and the last value is sent back into the ajax call again. All this works fine.
However, the problem i face is when i put thread.php in autorefresh using

<meta http-equiv="refresh" content="2">

When i do this, the returned response in my ajax call includes this and the json results which throws my looping of the json array off. I can remove the above code since i need thread.php to be constantly refreshing to poll data from the server. How do i get around this issue:

For reference:
thread.php

<meta http-equiv="refresh" content="2">
if(!isset($_GET['dateposted']))
{ $lastpost = 0; 
}
else
{$lastpost= $_GET['dateposted'];}



  $latestmsgs = retrieveNewMsgs($lastpost,$currtime);
  ?>

 <?php echo json_encode($latestmsgs);?>

index.php

var returnValue = (function() {
    var  dateposted = null;
    return function() {
        $.get("thread.php", { "lastMessage":  dateposted }, function(result) {
        if(result) {

                        for (var i = 0, len = result.length; i < len; i++) {

                            var msgs = result[i];
                            var newDiv = $("<div><img src='" + msgs[0] +"'/>" + msgs[2] + msgs[3] + msgs[4] + msgs[5] + "</div><br>");

                           $('#chatContents').append(newDiv);

                        }

                }

           dateposted = result[result.length-1][5];
        }, "json");
    }
})();
  • 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-29T20:04:15+00:00Added an answer on May 29, 2026 at 8:04 pm

    You could use the window.setInterval function to execute some javascript code at regular intervals of time that you define. So remove the meta refresh tag and place your AJAX call inside setInterval:

    // poll the server every 10 seconds for new data
    window.setInterval(function() {
        $.get("thread.php", ...
    }, 10000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form on my index.html page which makes a POST request to
I have the following scenario. I have a index.php page with the following JQuery
I have an index page index.php , and when the user clicks on a
I have a function that I use on index.php page and I would like
I have a page index.php where i have a link called add_users.php. In add_users.php,
I have an index.php file which has to process many different file types. How
I'm currently facing a strange problem in PHP. I have two scripts, index.php which
index.php has this jquery code which loads notifications.inc.php into a div on the page
In my website, website.com/downloads actually goes to website.com/index.php?page=downloads (with apache rewriting). I have a
I have 2 files, index.html and code.php. In my html page, I have a

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.