title: jQuery submit a js object via ajax to django view
body: <p>How do I submit a javascript object via jQuery to django?</p>
  
  <pre><code>$.ajax({
   type: 'POST',
   url: '/fetch-items/',
   data: {'foo': 'bar', 'foobar': {'spam': 'eggs'} },
   success: function(){
    alert('yey');
   }
  });
  </code></pre>
  
  <p>django part:</p>
  
  <pre><code>def fetch_items(request):    
      if request.is_ajax():
          print request.POST
  #output
  &gt;&gt;&gt; &lt;QueryDict: {u'foo': [u'bar'], u'foobar[spam]': [u'eggs']}&gt;
  </code></pre>
  
  <p>Why is 'foobar[spam]' a key and not 'foobar' a key to a dict {'spam': 'eggs'}?</p>