You should not use such arrays in Javascript. Arrays are numerically indexed. If you write
response[1]["Id"] = 2;
you add a property to the response array [1]
EDIT - I read a little better than your comment. It states:
// FYI: the output is an array of keys (for example, the response [0] .Id), keys:
So you have an array of objects.
This displays the data you receive.
var response = new Array;
response[0] = new Object();
response[1] = new Object();
response[2] = new Object();
response[0]["Id"] = 1;
response[0]["StreetAddress"] = 'xxx';
response[0]["Place"] = 'yyy';
response[1]["Id"] = 2;
response[1]["StreetAddress"] = 'xxx';
response[1]["Place"] = 'yyy';
response[2]["Id"] = 3;
response[2]["StreetAddress"] = 'xxx';
response[2]["Place"] = 'yyy';
and you can access them as follows:
jQuery.each(response, function(key, value){
for (key2 in value[key]){
if (value[key].hasOwnProperty(key2)){
alert(mine[key2])
}
}
});
source
share