如何通过密钥访问我的json哈希?
我有一个ajax电话
function populate_technician_info(public_info_id)
{
var advantage_id = $('#admin_info').data('advantage_id');
$.ajax({
type: 'POST',
url: '/ajax/get_technician_info',
data: {'advantage_id': advantage_id},
dataType: "json",
success: function(tech_1_info, tech_2_info)
{
alert(tech_1_info);
add_technician_row(tech_1_info, tech_2_info, public_info_id);
}
});
}
和一个java脚本函数来填充信息返回(现在它只是一个警报)。
function add_technician_row(tech_1_info, tech_2_info, public_info_id)
{
public_info_id = '#' + public_info_id;
$.each([tech_1_info, tech_2_info], function(index, value)
{
$.each(this, function (tech_index, tech_info)
{
alert("Tech 1: " + tech_info.empl_first_nm);
});
});
}
我的问题是如何通过密钥访问值?
我试过了明显的tech_info.key
但我没有运气,它返回undefined或哈希对象。
所以我知道我有正确的对象。
my $technician_1_results = $self->employee_data_hub->resultset('Advantage')->search({employee_id => $tech_1_employee_id});
my $tech_1_info = $technician_1_results->first;
$self->render(json => {tech_1_info => $tech_1_info, tech_2_info => $tech_2_info});