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