When making an ajax call and receiving JSON data (Data Attached), the data appears as follows after being converted to a String:
{
"shipments":[
{
"companyName":"TriStar Inc.",
"shipmentDate":null,
"transMode":"NDAY",
"paid":true,
"delDate":null,
"custRefInfo":{
"customerName":"DAISY N.",
"customerZip":"90544"
},
"orderStatus":true
},
{
"companyName":"Carbo Box",
"shipmentDate":null,
"transMode":"COUR",
"paid":true,
"delDate":null,
"custRefInfo":{
"customerName":"TOM K",
"customerZip":"07410"
},
"orderStatus":true
}
]
}
Viewing the JSON response in Firefox, it displays as:
[Object { companyName="TriStar Inc.", shipmentDate=null, transMode="NDAY", more...}, Object { companyName="Carbo Box", shipmentDate=null, transMode="COUR", more... } ]
The task at hand is to extract the companyName and customerName fields from this response. The current method being used is not effective:
load: function(response){
for(var i in response){
console.log(response.shipments[i].companyName);
}