autorefresh index and details (login user)
[django_unres.git] / django_simple / todo / templates / index.html
index 1aa90da..33bbd55 100644 (file)
                {% endfor %}            
        </ul>
 
+{% if not alldone %}
+<script src="/static/jquery.min.js"></script>
 
-{% endblock %}
\ No newline at end of file
+<script>
+function worker() {
+  $.ajax({
+    data:{csrfmiddlewaretoken: '{{ csrf_token }}'},
+    url: "/refresh_done/", 
+    type:"post",
+    success: function(data) {
+      window.location.href = "/refresh_done/";
+    },
+    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 %}