【发布时间】:2010-12-24 04:28:57
【问题描述】:
info = {
'phone_number': '123456',
'personal_detail': {'foo': foo, 'bar': bar},
'is_active': 1,
'document_detail': {'baz': baz, 'saz': saz},
'is_admin': 1,
'email': 'foo@bar.com'
}
return HttpResponse(
simplejson.dumps({'success':'True', 'result':info}),
mimetype='application/javascript')
if(data["success"] === "True") {
alert(data[**here I want to display personal_detail and document_details**]);
}
我该怎么做?
【问题讨论】:
-
尝试使用 jQuery 模板插件 (api.jquery.com/category/plugins/templates)。
-
这是一篇令人困惑的帖子,因为您在同一代码块中有 python 和 javascript,并且缺少用于发出 ajax 请求的代码。您传递给 getJSON 的 url 是什么?您还可以在 json 中使用本机 bool 类型,在 python 中使用 True,在 javascript 中使用 true。