title: Using Ajax in Django to display time of day every second
body: <p>I am looking for a simple example of how to display current time on a a page in a django project.  I have tried searching and have come up with the following (which does not update unless I refresh the page):</p>
  
  <p>Here is my urls.py:</p>
  
  <pre><code>from django.conf.urls import patterns, include, url
  from garageMonitor.views import *
  from django.contrib import admin
  
  admin.autodiscover()
  
  urlpatterns = patterns('',
    url('time', time, name="time"),
  )
  </code></pre>
  
  <p>Here is my views.py:</p>
  
  <pre><code>def time(request):
    now = strftime("%H:%M:%S", gmtime())
  
    time_dict = {"Time":now}
    return render_to_response('time.html', {'time': time_dict})
  </code></pre>
  
  <p>Here is time.html:</p>
  
  <pre><code>&lt;script type="text/javascript"
  src="/static/garageMonitor/scripts/refreshTime.js"&gt;
  window.onload = refreshTime;
  &lt;/script&gt;
  &lt;table id="test"&gt;&lt;tbody&gt;
  &lt;tr&gt;
  {% include "testing.html" %}
  &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;
  </code></pre>
  
  <p>Here is testing.html:</p>
  
  <pre><code>{% for label, value in temperature.items %}
        &lt;td &gt;{{ label }}&lt;/td&gt;
        &lt;td&gt;{{ value }}&lt;/td&gt;
  {% endfor %}
  </code></pre>
  
  <p>Here is my refreshTime.js:</p>
  
  <pre><code>function refresh() {
      $.ajax({
          url: '{% url monitor-test %}',
          success: function(data) {
              $('#test').html(data);
          }
          setInterval("refreshTime()", 1000);
      });
  }
  
  $(function(){
      refresh();
  });
  </code></pre>
  
  <p>I'd appreciate any help please.</p>
  
  <p>I looked at the code in the console.  It is complaining about the line:</p>
  
  <pre><code>$(function(){
  </code></pre>
  
  <p>(it does not like the "$")</p>