i have some code which i would like to update (refresh) if my file has been modified since and its on a loop so it would keep trying to push it though can some1 please help me make it work? here's the code;
<script>
var checkUrl="messages.php";
window.setInterval("checkForUpdate()", 1000);
var pageLoad = new Date().getTime();
function checkForUpdate() {
$.ajax(checkUrl, {
type : 'HEAD',
success : function (response, status, xhr) {
if(firstCheck === false) {
firstCheck = true;
return;
}
var lastModified = new Date(xhr.getResponseHeader('Last-Modified'))
.getTime();
if(lastModified > pageLoad) {
window.location.replace("./");
}
}
});
}
</script>