Reputation: 5817
I have a single html page with a basic load() function that changes the contents of a div "content". The content in the loaded page are dynamic and subject to change. I tested by changing the content and then testing live on the web app. The problem is that the newly saved content is not updated and the page that is loaded is what was previously before the saved changes. I refresh multiple times but get the same results. It fixes by restarting the browser, but I want the page to be updated within the same session.
<script type="text/javascript">
$(document).on("click",".a", function () {
$("#content").load(this.href);
return false;
});
</script>
Upvotes: 0
Views: 30
Reputation: 34426
Add a timestamp (or other unique string) to the load statement URL to prevent caching -
$(document).on("click",".a", function () {
var timestamp = Date.now().toString();
$("#content").load(this.href + '?' + timestamp);
return false;
});
Upvotes: 1