Hello,
I cannot seem to make this simple code work:
<script type="text/javascript">
$(document).ready(function(){
$.getJSON('http://maps.google.com/maps/api/geocode/json?address=cebu&sensor=false&region=ph',
function(results) {
alert(results);
});
});
</script>
It always alerts null even though the results for the json is something like this:
{
"status": "OK",
"results": [ {
"types": [ "locality", "political" ],
"formatted_address": "Cebu City, Philippines",
"address_components": [ {
"long_name": "Cebu City",
"short_name": "Cebu City",
"types": [ "locality", "political" ]
}, {
"long_name": "Cebu",
"short_name": "Cebu",
"types": [ "administrative_area_level_2", "political" ]
}, {
"long_name": "Central Visayas",
"short_name": "Central Visayas",
"types": [ "administrative_area_level_1", "political" ]
}, {
"long_name": "Philippines",
"short_name": "PH",
"types": [ "country", "political" ]
} ],
"geometry": {
"location": {
"lat": 10.3455617,
"lng": 123.8969328
},
"location_type": "APPROXIMATE",
"viewport": {
"southwest": {
"lat": 10.3016523,
"lng": 123.8329031
},
"northeast": {
"lat": 10.3894650,
"lng": 123.9609625
}
},
"bounds": {
"southwest": {
"lat": 10.2594350,
"lng": 123.8668156
},
"northeast": {
"lat": 10.3991826,
"lng": 123.9401150
}
}
}
} ]
}
What else do I need to do? I have read back-and-forth the jquery manual but I cannot seem to make the simple example work.
Thanks!