reload uses timeout
This commit is contained in:
@@ -9,29 +9,31 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script>
|
||||
var previous = null;
|
||||
var current = null;
|
||||
$(document).ready(function() {
|
||||
$.getJSON('http://localhost:8000/rowers/list-jobs/', function(json) {
|
||||
current = JSON.stringify(json);
|
||||
previous = current;
|
||||
});
|
||||
console.log('initial poll');
|
||||
});
|
||||
<script type='text/javascript'
|
||||
src='http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.jQuery || document.write('<script src="/static/js/jquery-3.1.0.js"><' + '/script>');
|
||||
</script>
|
||||
|
||||
setInterval(function() {
|
||||
$.getJSON('http://localhost:8000/rowers/list-jobs/', function(json) {
|
||||
|
||||
<script>
|
||||
var previous = null;
|
||||
var current = null;
|
||||
(function checkJobs() {
|
||||
console.log('polling');
|
||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/list-jobs/', function(json) {
|
||||
current = JSON.stringify(json);
|
||||
if (previous && current && previous !== current) {
|
||||
console.log('refresh');
|
||||
location.reload();
|
||||
};
|
||||
previous = current;
|
||||
});
|
||||
console.log('polling');
|
||||
}, 15000)
|
||||
console.log('refresh');
|
||||
location.reload();
|
||||
};
|
||||
previous = current;
|
||||
});
|
||||
setTimeout(checkJobs, 15000);
|
||||
}());
|
||||
|
||||
</script>
|
||||
|
||||
<script src="/static/cookielaw/js/cookielaw.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user