我有麻烦,从谷歌地图APIjQuery和谷歌地图JSON响应
获取地理位置信息的代码是非常简单的
$.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");
}
我总是得到一个错误回来。 我直接尝试过(我在其他地方见过回调应在年底前成立...
$.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.");
}
});
请求的URL是正确形成:
,它给我正确的JSON
请指教!
你可以 '玩' 与它在http://jsfiddle.net/PNad9/
感谢队友,这节省了我很多时间。 – Jack 2013-01-04 19:15:45