Ciao a tutti, ho creato una funzione ajax la quale mi restituisce un array json multidimensionale.
Purtroppo ho provato a fare un ciclo for ma non riesco a stampare correttamente i dati.
Questo il codice della chiamata ajax:
codice:
$.ajax({
type: 'POST',
url: $url,
data: {id:postData},
dataType: "json",
success: function(data) {
console.log(JSON.stringify(data.IndexParent, null, 4));
console.log('********************************************');
console.log(JSON.stringify(data.parent, null, 4));
console.log('********************************************');
console.log(JSON.stringify(data.productionIndex, null, 4));
ecc........
quello che visualizzo stampando questi 3 array è:
codice:
{
"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",
"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": "31396",
"PLANTS_id": "14",
"INDEX_LIST_id": "3",
}
]
}
con il codice seguente ottengo correttamente l'indice ma poi non so come poter accedere al valore.
codice:
var index = [];
for (var x in data.IndexParent) {
console.log('DDD: '+x);
index.push(x);
}
In questo modo riesco ad ottenere gli indici ma se poi passo a fare un ciclo for o altro non riesco a stampare nulla, mi da sempre INDEX 12 VAULE [object object], [object object], [object object]
dove l'indice è corretto ma non accedo al valore.
codice:
var myArray = new Array();
myArray = data.IndexParent;
$.each(myArray, function(index, value){
console.log("INDEX: " + index + " VALUE: " + value);
});
Come posso procedere?
Qualche aiuto? 

Grazie