1

Please excuse my bad english, I'm french ;)

SO, I've to make an Ajax call you this kind of url : http://maps.googleapis.com/maps/api/geocode/json?latlng=45.85941212790755,0&sensor=true

With this code :

$.ajax({ url:'http://maps.googleapis.com/maps/api/geocode/json?latlng='+pos.coords.latitude+','+pos.coords.longitude+'&sensor=true',
          success: function(results){
              // ...
          }
        });

But it never succeeds for IE8 (It's ok for chrome and FF, IE9&10).

Have you got an idea ?

j0k
  • 22,600
  • 28
  • 79
  • 90
Florian Mac Langlade
  • 1,863
  • 7
  • 28
  • 57

1 Answers1

2

EDIT

My bad, in IE8 you cannot request a geocode from the client side any longer because google has removed JSONP support from their geocoder.

You can do one of two things

  1. Use your own server as a proxy (I do this). This basically means that you make a request to a script on your own server that uses cURL (or similar) to make a request to the google geocoder and then return the results back to you.

  2. If you're using the google maps api, you have the option of using it's built-in geocoder (https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple)

OLD REPLY

It's a cross domain call in IE8 - you'll get a No Transport error (or if you add jQuery.support.cors = true you'll still get an Access is Denied error.

Best solutions is to use JSONP. jQuery makes using JSONP trivial.

Check out this jQuery Docs page and scroll down to their example using JSONP with the Flickr API.

Adam Jenkins
  • 51,445
  • 11
  • 72
  • 100