views:

42

answers:

1

Hi all,

I have a problem with a Javascript request to the Google Map Api Web Service : if I have the HTML file on my computer it works, but it doesn't work online.

Here's the code :

url = 'http://maps.google.com/maps/api/geocode/json?address=Senador+Francisco+Quindimil+Y+Carabobo+Por+Carabobo,Ciudad+Autonoma+de+Buenos+Aires,Argentina&sensor=false';

$.get(url, function(data) {
  $('#result').html(data);
  alert('Load was performed.');
}, 'text');

This sample is just supposed to load the "data" in the "result" element. When it is offline, the "data" has text, but not when it is online.

Sample here : Online Web Service Test

Could one of you guys help ?

Thanks a lot !

+2  A: 

You are experiencing the same origin policy. You'll need to setup a server-side proxy (HTTP handler) to hit up Google Maps out in the wild.

Josh Stodola
Thank you ! For those who experience the same problem I recommend this resource to make the proxy http://developer.yahoo.com/javascript/howto-proxy.html
Julien
@Julien You are welcome! I have updated my answer to include a link to that page. That is a very good explanation of the problem.
Josh Stodola