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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:16:03+00:00 2026-05-28T06:16:03+00:00

Update : success progress but still a problem : new data reloaded after refreshing

  • 0

Update : success progress but still a problem : new data reloaded after refreshing the page twice it’s ok to refresh the page once every 10 or 15 minutes but one ferfesh doesn’t display the new data from the text file though it already contains the new data came from getData.php file

getData.php code

$connect = mysql_connect("localhost","root","");
$db = mysql_select_db("mydb",$connect);

$getTextQ = "select * from text";
$getTextR = mysql_query($getTextQ);
$path = "text/";
$myfile = $path."data.txt";
$open = fopen($myfile,"w");
while($row = mysql_fetch_array($getTextR)){
    $write = fwrite($open,"<div class='slide'><h1>".$row['id']."</h1><p>".$row['desc']."</p></div>");       
}
$close = fclose($open);
mysql_close($connect);

index.php code

<script src="js/jquery-1.7.1.js"></script>
<script src="js/slides.min.jquery.js"></script>
<script>
    $(function(){
            $.ajax({
            url: 'getData.php',
            type: 'POST'
            });
        });         
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "text/data.txt", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4) {
if (txtFile.status === 200) {
allText = txtFile.responseText;
}
}
}
txtFile.send(null);

    });

</script>

html code

<div id="mydiv" class="slides_container">                               
<?php $path ="text/"; 
$open = fopen($path."data.txt","r"); 
$read = fread($open,50000); 
$close = fclose($open); 
echo $read; 
?>
</div>
  • 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-28T06:16:04+00:00Added an answer on May 28, 2026 at 6:16 am

    I would not have the php file write to a text file and then read the text file; you are doing two ajax calls / requests to the server where only one is needed.

    Apart from that it could lead to errors on the server when two instances try to write at the same file at the same time.

    If you change your getData.php to echo out the values instead of storing them in a text file, you can simplify your javascript to:

    $("#myDiv").load("getData.php");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I submit an update to UpdateListItems. It returns success but the list item ahs
UPDATE (5/21/2010) SUCCESS! So after MUCH $head->desk()'ing, I've solved it. Remember kids, be wary
UPDATE 1: I can get around the problem with a try/catch, but I would
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:
In the code example below the success callback function logs 'input#04.update' four times rather
UPDATE : After having restarted my BIDS, deleted my dll from GAC and task
Set Success page redirection in google checkout ? i have already set callback URL
Update: Problem solved, and staying solved. If you want to see the site in
I'd like to update the value of a field only if the new one
Update: Solved, with code I got it working, see my answer below for the

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.