How can I refresh a page with jQuery?
Here is a solution that asynchronously reloads a page using jQuery. It avoids the flicker caused by window.location = window.location
. This example shows a page that reloads continuously, as in a dashboard. It is battle-tested and is running on an information display TV in Times Square.
...
...
Notes:
$.ajax
directly like $.get('',function(data){$(document.body).html(data)})
causes css/js files to get cache-busted, even if you use cache: true
, that's why we use parseHTML
div
http-equiv="refresh"
just in case something goes wrong with javascript/server hiccup, then the page will STILL reload without you getting a phone callhttp-equiv
refresh fixes that