I am having troubles getting geo location info from google maps api
the code is pretty straight forward
$.ajax({
type: "GET",
cache: false,
url: "http://maps.googleapis.com/maps/api/geocode/json",
dataType: "jsonp",
data: {
address: "Ljubljana " + "Slovenia",
sensor: "false"
},
jsonpCallback:'json_response',
success: function(data) {
top.console.debug(data);
$('#location_setter').dialog('close');
},
error: function() {
alert("Error.");
}
});
function json_response(data){
alert("works");
}
I always get an error back. I tried directly too (I read somewhere that the callback should be set at the end...
$.ajax({
type: "GET",
cache: true,
url: "http://maps.googleapis.com/maps/api/geocode/json?address=Ljubljana Slovenia&sensor=false",
dataType: "jsonp",
jsonpCallback:'json_response',
success: function(data) {
top.console.debug(data);
$('#location_setter').dialog('close');
},
error: function() {
alert("Error.");
}
});
the request url is correctly formed:
and it gives me the correct json
please advise!
You can 'play' with it at http://jsfiddle.net/PNad9/