How can I access my json hash by key?
I have an ajax call
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);
}
});
}
and a java script function to populate the information return (for now it's just an alert).
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);
});
});
}
My question is how can I access the values by key?
I have tried the obvious tech_info.key
But I'm having no luck, it returns undefined or a hash object.
But If i just print tech_info
I get
So I know I have the correct object.
The data is definitely there I have double checked it by printing the values from perl to the terminal.
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});