Skip to content

Instantly share code, notes, and snippets.

@mortenson
Created September 8, 2015 20:05
Show Gist options
  • Save mortenson/1ef6d409f05523865aed to your computer and use it in GitHub Desktop.
Save mortenson/1ef6d409f05523865aed to your computer and use it in GitHub Desktop.
Refresh current path in JS every 5 seconds (try it out by editing the content of body)
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
$(function() {
if (typeof init === 'undefined') {
init = true;
setInterval(function () {
$.get('', function (data) {
var doc = document.open('text/html', 'replace');
doc.write(data);
doc.close();
});
}, 5000);
}
});
</script>
</head>
<body>
Hello world.
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment