问题描述
我确定我不是唯一一个,但是当 jQuery 请求查找地址时,当请求的数据是 latitude
和 时,我无法解析/返回任何内容经度
这样Google可以返回数据,但是jQuery无法读取?
I'm sure I'm not the only one, but I cannot parse/return anything when jQuery takes a request to lookup an address when the data being requested is the latitude
and longitude
so Google can return the data, but it cannot be read by jQuery?
http://maps.googleapis.com/maps/api/geocode/json
带参数:
latlng=51.276914,1.077252
&sensor=false
在 Firebug 中显示 200 OK
但响应中没有显示任何内容:
In Firebug it says 200 OK
but nothing is displayed in the response:
I can see it when I open it: http://maps.googleapis.com/maps/api/geocode/json?latlng=51.187296,1.229086&sensor=false&_=1302084865163
我所做的是:
$.ajax(
{
url: 'http://maps.googleapis.com/maps/api/geocode/json',
data: 'latlng=' + geolocation + '&sensor=false',
dataType: 'json',
cache: false,
success: function(data){ alert(data); }
});
这不起作用... $.get
、$.getJSON
和 json
dataType
.
That doesn't work... neither $.get
, $.getJSON
with the json
dataType
.
为什么 jQuery 不能解析/读取响应?
Why can't jQuery parse/read the response?
推荐答案
出于安全考虑,您需要使用 googles geocoder.请在此处查看答案.
You need to use googles geocoder for security reasons. See answer here.
这篇关于使用 jQuery 解析 Google Geo API(反向地理编码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!