Skip to content

Instantly share code, notes, and snippets.

@bitboxx
Created March 13, 2013 13:06
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitboxx/5151870 to your computer and use it in GitHub Desktop.
Save bitboxx/5151870 to your computer and use it in GitHub Desktop.
Javascript / jQuery: Detect page change using AJAX; auto refresh if the page is updated
// Detect page change / auto refresh
$(document).ready(function() {
var currenthtml;
var latesthtml;
$.get(window.location.href, function(data) {
currenthtml = data;
latesthtml = data;
});
setInterval(function() {
$.get(window.location.href, function(data) {
latesthtml = data;
});
if(currenthtml != latesthtml) {
location.reload();
}
}, 5000);
});
@MENDELKAHAN
Copy link

I want an alert there a change however after the first alert it just keeps on coming even though there are no more changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment