$(document).ready(function(){
var modTime = 0;
setInterval(function(){
$.post("ChatClient.php", {"file":"chat.cht", "time":modTime}, function(rst) {
if (rst.time != modTime) {
modTime = rst.time;
window.location.reload();
else {
}
}
});
}, 1000);
});
So that is my code, and I need to make it do the whole check again on the else-statemen.
This is supposed to check a file modification time and if it's changed - it should reload the page and if it's not changed, it should just keep checking infinitely again until it is.
It works nice, if I remove the else-statement but then it refreshes every seconds - no matter if the file is modified or not.
I tried this by myself:
$(document).ready(function(){
loopIt();
function loopIt() {
var modTime = 0;
setInterval(function(){
$.post("ChatClient.php", {"file":"chat.cht", "time":modTime}, function(rst) {
if (rst.time != modTime) {
modTime = rst.time;
window.location.reload();
else {
loopIt();
}
}
});
}, 1000);
}
});