Created
March 13, 2013 13:06
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want an alert there a change however after the first alert it just keeps on coming even though there are no more changes