I have a problem with a json array.
I have created a jquery ajax function
$.ajax({
type: 'POST',
url: $url,
data: {id:postData},
dataType: "json",
success: function(data) {
console.log(JSON.stringify(data.productionIndexParent, null, 4));
console.log(JSON.stringify(data.parentPlants, null, 4));
console.log(JSON.stringify(data.productionIndex, null, 4));
},
error: function(x, t, m) {
if(t==="timeout") {
alert("got timeout");
} else {
alert(t);
}
}
});
On my codeigniter I print an array data.
echo json_encode($data);
The console.log result is:
{
"12": [
{
"id": "25284",
"PLANTS_id": "12",
"INDEX_LIST_id": "1",
},
{
"id": "26048",
"PLANTS_id": "12",
"INDEX_LIST_id": "2",
},
{
"id": "26812",
"PLANTS_id": "12",
"INDEX_LIST_id": "3",
}
]
}
[
{
"id": "12",
"idParent": null,
"PLANTS_id": "12",
"SERVICE_STATE_id": "3",
"last_update_time": "2014-01-27 00:00:00"
}
]
{
"13": [
{
"id": "27576",
"PLANTS_id": "13",
"INDEX_LIST_id": "1",
},
{
"id": "28340",
"PLANTS_id": "13",
"INDEX_LIST_id": "2",
},
{
"id": "29104",
"PLANTS_id": "13",
"INDEX_LIST_id": "3",
}
],
"14": [
{
"id": "29868",
"PLANTS_id": "14",
"INDEX_LIST_id": "1",
},
{
"id": "30632",
"PLANTS_id": "14",
"INDEX_LIST_id": "2",
},
{
"id": "31396",
"PLANTS_id": "14",
"INDEX_LIST_id": "3",
}
]
}
now how i can parse the object array? I have many problems and I don't know how I can parse this array. Thanks F