I have a json file that looks like this:
{
"status": 200,
"data": {
"employeeId": "515552",
"firstName": "Name",
"lastName": "LastName",
"locationName": "Location Name",
"businessUnitName": "Unit",
"workPhone": "212/465-5555",
"cellPhone": "646/261-5555",
"faxNumber": "",
"assistant": "",
"email": "[email protected]",
"reportsTo": [
{
"employeeId": "533953",
"firstName": "Howard",
"lastName": "Jacobs",
"jobTitle": "EVP Marketing & Sales Teams"
}
],
"departnemtId": "649654910",
"departnemtName": "Action Sports Administration",
"jobTitle": "VP Action Sports/Transform Dev"
}
}
I am using an Ajax call to push the data into an array, but I can't seem to figure out the proper way to get to the reportsTo data. It's the last one and I'm getting Undefined:
// Load the Employee Details on the index.page
$.ajax({
url: "user-details-515552.json",
cache: true,
dataType : 'json',
success : function(results) {
var employeeData = [];
employeeData.push({
assistant: results.data.assistant,
departmentID: results.data.departnemtId,
departmentName: results.data.departnemtName,
locationName: results.data.locationName,
reportsToName: results.data.reportsTo.employeeId
});
$('#employee-details').tmpl(employeeData).appendTo('#results-container');
}
});