【发布时间】:2012-01-05 15:32:24
【问题描述】:
我在 django 模板中通过 jquery/Ajax 获得 JSON 响应,如下所示:
[{"total_count": {"3": 1}, "all_user_request": [{"pk": 3, "model": "new_tracker.new_request", "fields": {"status": "Open", "severity": "High", "title": "New Year wish", "last_modified_date": "05-01-2012", "creation_date": "05-01-2012", "priority": "High", "department": "IT", "primary_assignee": "John", "creator": "Martin", "description": "Martin has requested on Thu Jan 05 2012 18:19:53:<br />Happy new year"}}]}]
现在我想使用 Jquery 对其进行反序列化。谁能帮我实现这一目标?到目前为止,我尝试过这样但没有运气,
success: function( all_user_request ){
$.each( all_user_request, function( key, value ){
request_id = value.all_user_request.pk;
total_count = value.total_count.request_id;
status = value.all_user_request.fields.status;
........code follows like this
如果信息不完整,请告诉我。我在序列化时使用了 simplejson.dumps。
提前致谢, 苏尼尔
【问题讨论】:
-
让我们看看您实际发出请求的实际 javascript。
-
我不知道这个问题的答案,但是当您在大小为 1 的数组中确实有字典/对象时,您似乎正在尝试遍历字典。
-
也许这会对你有所帮助:stackoverflow.com/questions/2112831/…
-
javascript 控制台、console.log() 和 js 调试器(断点,...)在这里可以为您提供很多帮助;)