Skip to content Skip to sidebar Skip to footer

Webbrowser Is Not Showing The Updated Version Of A Txt File But Opening A New Browser Shows Correct File

I'm experimenting with PHP together with Ajax and JQuery to make a site where I can write to a text file and then have the site load the textfile's contents into a div. This is the

Solution 1:

Append a time string to the title of the file in the load statement to prevent caching -

$(document).ready(function() {
    setInterval(function() {
        var ms = (newDate).getTime(); // epoch time
        $("#text").load("storydoc.txt?ms=" + ms ); // add query string
    }, 2000);
});

The added string is inconsequential to the actual file but will have the affect of making the request 'new' each time because the added time string will be different and there will not be a copy in the cache.

Post a Comment for "Webbrowser Is Not Showing The Updated Version Of A Txt File But Opening A New Browser Shows Correct File"