【发布时间】:2010-11-15 12:52:30
【问题描述】:
我正在尝试使用 Django/Python 处理传入的 JSON/Ajax 请求。
request.is_ajax() 是请求中的True,但我不知道 JSON 数据的负载在哪里。
request.POST.dir 包含以下内容:
['__class__', '__cmp__', '__contains__', '__copy__', '__deepcopy__', '__delattr__',
'__delitem__', '__dict__', '__doc__', '__eq__', '__ge__', '__getattribute__',
'__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__',
'__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__setitem__', '__str__', '__weakref__', '_assert_mutable', '_encoding',
'_get_encoding', '_mutable', '_set_encoding', 'appendlist', 'clear', 'copy', 'encoding',
'fromkeys', 'get', 'getlist', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues',
'keys', 'lists', 'pop', 'popitem', 'setdefault', 'setlist', 'setlistdefault', 'update',
'urlencode', 'values']
请求发布键中显然没有键。
当我查看Firebug 中的 POST 时,请求中发送了 JSON 数据。
【问题讨论】:
-
您实际发布的是什么?向我们展示 javascript 调用。
-
len(request.POST)和request.POST.items()也会有所帮助。
标签: python ajax json django content-type