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

  • Home
  • SEARCH
  • 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 3343500
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:57:42+00:00 2026-05-18T00:57:42+00:00

Background: My webpage loads entries from an XML file via AJAX/jQuery and displays them

  • 0

Background:

My webpage loads entries from an XML file via AJAX/jQuery and displays them (works fine)

The page also has a form that submits via AJAX/jQuery to a PHP file which writes to the XML file, then reloads the XML entries via AJAX/jQuery and displays them (works fine)

I have the following odd problem:

If I delete the XML file through FileZilla, or try to overwrite the XML file by uploading a copy from my local machine, the entries do not change at all when I’m looking at my page. In fact, if overwrite the XML file with a new copy, I see the new copy if I navigate to it in my address bar like: http://mysite.com/myxmlfile.xml, however, in the page that displays the XML entries, the old entries (like the file was never overwritten/deleted) are still displayed!

Confused!


Here’s my PHP file:

<?php

    header('Pragma: no-cache');
    header('Cache: no-cache; must-revalidate;');

    function signGuestbook($entry){

        $date = date("n.d.Y");
        $name = $entry['name'];
        $email = $entry['email'];
        $comment = $entry['comment'];

        $doc = new DOMDocument();
        $doc->preserveWhiteSpace = false;
        $doc->load('guestbook.xml');

        $root = $doc->firstChild;
        $e = $doc->createElement('entry');
        $dateNode = $doc->createElement('date', $date);
        $nameNode = $doc->createElement('name', $name);
        $emailNode = $doc->createElement('email', $email);
        $commentNode = $doc->createElement('comments', $comment);

        $e->appendChild($dateNode);
        $e->appendChild($nameNode);
        $e->appendChild($emailNode);
        $e->appendChild($commentNode);

        $root->appendChild($e);
        $doc->formatOutput = true;
        $doc->save('guestbook.xml');
    }

    function loadGuestbook(){

        $gBook = new DOMDocument();
        $gBook->load('guestbook.xml');

        $entries = $gBook->getElementsByTagName('entry');
        $entries_arr = array();

        foreach($entries as $entry)
        {
            $date    = $entry->getElementsByTagName('date')->item(0)->nodeValue;
            $name    = $entry->getElementsByTagName('name')->item(0)->nodeValue;
            $email   = $entry->getElementsByTagName('email')->item(0)->nodeValue;
            $comment = $entry->getElementsByTagName('comments')->item(0)->nodeValue;

            $entries_arr[] = array(
                'date'    => $date,
                'name'    => $name,
                'email'   => $email,
                'comment' => $comment
            );
        }

        return json_encode($entries_arr);
    }

    $entry = json_decode(stripcslashes($_POST['entry']), true);

    if($entry != null){

        signGuestbook($entry);
    }


    header("Content-type: text/plain");
    echo loadGuestbook();

    ?>

Here’s my JS file:

$(document).ready(function(){
    $.post('guestbook.php?' + new Date().getTime(), loadGuestbook, "text");
});

function loadGuestbook(gBook){

    var gBookDiv = $('div#guestbook');
    gBookDiv.empty();

    var entries = JSON.parse(gBook);

    $.each(entries, function(i, entry){

        gBookDiv.prepend(
            '<div class="entry">' +
            '<span class="date">' + entries[i].date + '</span>' +
            '<strong class="blue">Name:</strong><span class="name">' + entries[i].name+ '</span><br />' +
            '<strong class="blue">Email:</strong><span class="email">' + entries[i].email + '</span><br />' +
            '<strong class="blue">Comments:</strong><p>' + entries[i].comment + '</p>' +
            '</div>'
        );
    });
}

function signGuestbook(){

    var name    = $('input#name').val();
    var email   = $('input#email').val();
    var comment = $('textarea#comments').val();

    if(name == null || name == '' || email == null || email == ''){
        alert('You must provide a name and email.');
    }

    else{

        var entry = {
            "name"    : name,
            "email"   : email,
            "comment" : comment
        };

        var entryString = JSON.stringify(entry);
        $.post('guestbook.php?' + new Date().getTime(), { entry : entryString }, loadGuestbook, "text");

        $('input#name').val('');
        $('input#email').val('');
        $('textarea#comments').val('');
    }
}
  • 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-18T00:57:42+00:00Added an answer on May 18, 2026 at 12:57 am

    This is a caching issue. To prevent your Ajax calls from being cached add the time to your Ajax call:

    $.post('myphp.php?' + new Date().getTime(), { my : dataString }, myFunction, "text");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to just change the background colour of a webpage upon page load.
I have a webpage where I am loading a twitter feed via ajax. My
Ive got two div's on a webpage, which need to be hidden from page
I have a webpage with ajax. Ajax HAS to load some data from other
Background XSL translates an XML document into a stylized web page. The user can
I have a WebView that is fed from a background thread via a ServerSocket
I have a web page that loads two images from a css sprite like
I am trying to setting up the background image of the webpage outside the
Is there away to set a background image on a webpage when the webpage
I want to create a web page background image that fills the entire background,

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.