title: Django, jQuery, XMLHttpResponse error
body: <p>I'm trying to learn some basic ajax using Django.  My simple project is an app that randomly selects a <code>Prize</code> from the available prizes in the database, decrements its quantity, and returns <code>prize.name</code> to the page.</p>
  
  <p>I'm using jQuery's $.ajax method to pull this off.  The the only thing that's running is the <code>error</code> function defined in my $.ajax call, but the error message says nothing but "error".  I'm new to ajax, so I'm probably overlooking something obvious.  Here's the relevant code:</p>
  
  <h2>Model</h2>
  
  <pre><code>class Prize(models.Model):
      name = models.CharField(max_length=50)
      quantity = models.IntegerField(default=0)
  
      def __unicode__(self):
          return self.name
  </code></pre>
  
  <p><br></p>
  
  <h2>URLConf</h2>
  
  <pre><code>urlpatterns = patterns('',
      (r'^get_prize/$', 'app.views.get_prize' ),
  )
  </code></pre>
  
  <p><br></p>
  
  <h2>View</h2>
  
  <pre><code>def get_prize(request):
      prizes = Prize.objects.filter(quantity__gt=0)
      to_return = {}
  
      if prizes:
              rand = random.randrange(len(prizes))
          prize = prizes[rand]
          prize.quantity -= 1
          prize.save()
  
  
          to_return['prize'] = prize.name
          data = simplejson.dumps(to_return)
  
          return HttpResponse(data, mimetype='application/json')
  
  
      else:
          to_return['msg'] = "That's all the prizes.  No more."
          data = simplejson.dumps(to_return)
  
          return HttpResponse(data, mimetype='application/json')
  </code></pre>
  
  <p><br></p>
  
  <h2>Template</h2>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;title&gt;User's Conference Prize Randomizer&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="/static-media/style.css" /&gt;
  &lt;script type="text/javascript" src="/static-media/jquery-1.2.6.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      var get_prize = function() {
          var args = { 
              type: "GET",
              url: "get_prize",
              dataType: "json",
              success: done,
              error: function(response,error_string,e){
                  alert( "Error: " + response.responseText + " " + error_string ); 
                  for (i in e){
                      alert(i);
                  }
              }
          };
  
          $.ajax(args);
      };
  
      var done = function(response) {
          if(response)    {
              alert(response);
          }
  
          else {
              alert("Something boo-booed");
          }
      };
  
      $(document).ready(function() {
         $("#start").click(get_prize);
       });
  &lt;/script&gt;
  
  &lt;/head &gt;
  
  &lt;body&gt;
          &lt;p&gt;&lt;a href="" id='start'&gt;Get Prize&lt;/a&gt;, this link isn't working how I'd like.&lt;/p&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>