Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

With parameters:

latlng=51.276914,1.077252
&sensor=false

In Firebug it says 200 OK but nothing is displayed in the response:

enter image description here

I can see it when I open it: http://maps.googleapis.com/maps/api/geocode/json?latlng=51.187296,1.229086&sensor=false&_=1302084865163

What I did was:

$.ajax(
{
    url: 'http://maps.googleapis.com/maps/api/geocode/json',
    data: 'latlng=' + geolocation + '&sensor=false',
    dataType: 'json',
    cache: false,
    success: function(data){ alert(data); }
});

That doesn't work... neither $.get, $.getJSON with the json dataType.

Why can't jQuery parse/read the response?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to use googles geocoder for security reasons. See answer here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...