我在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。
提前致谢, 苏尼
答案 0 :(得分:0)
json的解析应该在请求点发生。
jQuery会自动执行此操作,只要您将'json'
指定为dataType。