I want to nest an array value inside another array. I'm uncertain why this won't work:
$.getJSON("test.js", function(json){
varservers=["test02","test07","test08","test01","test05"];
for(vari=0;i<servers.length;i++){
var mine=[json.server[0].servers[i][0].version,json.server[0].servers[i][0].SerialNumber,json.server[0].servers[i][0].Manufacturer,json.server[0].servers[i][0].FreePhysicalMemory];
$("div").append("<div>Version: "+mine[0]+"</div><div>Serial Number: "+mine[1]+"</div><div>Manufacturer: "+mine[2]+"</div><div>FreePhysicalMemory: "+mine[3]+"</div>");
};
});
Here is the json format saved as js. It works if I don't make the servers an array:
{
"server": [
{
"test02": [
{
"version": "5.2.3790",
"SerialNumber": "69712-640-24775",
"Manufacturer": "Microsoft Corporation",
"FreePhysicalMemory": "182128"
}
]
},
{
"test07": [
{
"version": "5.2.3790",
"SerialNumber": "69713-650-26411",
"Manufacturer": "Microsoft Corporation",
"FreePhysicalMemory": "4101680"
}
]
},
{
"test08": [
{
"version": "5.2.3790",
"SerialNumber": "69712-650-4015",
"Manufacturer": "Microsoft Corporation",
"FreePhysicalMemory": "2578328"
}
]
},
{
"test05": [
{
"version": "6.1.7601",
"SerialNumber": "00477-001-004673",
"Manufacturer": "Microsoft Corporation",
"FreePhysicalMemory": "744060"
}
]
},
{
"test04": [
{
"version": "6.1.7601",
"SerialNumber": "00477-001-04534",
"Manufacturer": "Microsoft Corporation",
"FreePhysicalMemory": "14263600"
}
]
}
]
}
*This post was edited by another user to make the json look more editable, but the change made the jquery coding long and hard to read. I changed that code back to its previous state.