i'm loading in jquery a google map json and i receive correctly the json object called 'data'
sometimes — i can't identify exactly when or why and that's why i came here — even if i receive the regular values, BUT firebug console reads it is undefined!
for example, I have this line below in my js:
console.log(data.Placemark[i].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber);
in my Firebug Console i can see first the right value of the zipcode (10018), THEN i see this error:
data.Placemark[i].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode is undefined
i mean, if I get the value.. how could it be that is undefined??
here the complete code
$.ajax(
{
dataType: 'json',
url: "http://maps.google.com/maps/geo?q=" + myaddress + "&key=" + myapiKey + "&sensor=false&output=json&callback=?",
success: function (data, textStatus)
{
for (i = 0; i < data.Placemark.length; i++)
{
console.log(data.Placemark[i].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber);
}
},
error: function (data)
{
/*nothing*/
}
});
I can add another detail: the error happens only when data.length is > 1 (basically when i get more than one address corresponding to my input)