autorefresh in js details1.html every 30sec
authorCezary Czaplewski <czarek@chem.univ.gda.pl>
Mon, 8 Jan 2018 14:44:00 +0000 (15:44 +0100)
committerCezary Czaplewski <czarek@chem.univ.gda.pl>
Mon, 8 Jan 2018 14:44:00 +0000 (15:44 +0100)
django_simple/todo/templates/details1.html

index c5c1273..052d84d 100644 (file)
@@ -640,5 +640,28 @@ function showDivs(n) {
 }
 </script>
        
+{% if not task.done %}
+<script>
+function worker() {
+  $.ajax({
+    data:{csrfmiddlewaretoken: '{{ csrf_token }}'},
+    url: "/refresh_done1/{{task.id}}/", 
+    type:"post",
+    success: function(data) {
+      document.location.reload();
+    },
+    complete: function() {
+      // Schedule the next request when the current one's complete
+      setTimeout(worker, 30000);
+    }
+  });
+};
+$(document).ready(function() {
+  // run the first time; all subsequent calls will take care of themselves
+  setTimeout(worker, 30000);
+});
+</script>
+{% endif %} 
+
        
 {% endblock %}