如何在jQueryAjax中解析json数据?

如何在jQueryAjax中解析json数据?,jquery,python,ajax,Jquery,Python,Ajax,我怎样才能做到这一点呢?如果我正确理解了这个问题,可能是您在寻找的 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 Htt

我怎样才能做到这一点呢?

如果我正确理解了这个问题,可能是您在寻找的

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**]);
}
$。getJSON
使用您提供的urlencoded参数(第二个参数)向提供的url(第一个参数)发送一个
GET
请求,并在成功时使用来自服务器的JSON解码结果调用success函数(第三个参数)(
result


这是一个使用
$.ajax
并手动调用
$.parseJSON
等的快捷版本。

尝试使用jQuery模板插件()。这是一篇令人困惑的文章,因为您在同一代码块中有python和javascript,并且发出ajax请求的代码缺失。传递给getJSON的url是什么?您还可以在json中使用本机bool类型,在python中为True,在javascript中为True。
$.getJSON('/ajax_url/',
    {
        'some_data': 'Some Value'
    },
    function(result){
        alert(result.personal_detail.foo);
    }
);