0

I have an ajax function in my script that works fine in all browsers except ie9 and below.

I've read elsewhere on Stackoverflow (jQuery.getJSON not working properly in IE8 with gdata json-c. Why?) that this could be a cross domain issue but if it was that surely my code would fail in all browsers?

Can anybody provide me with some advice?

function GetLocation(location) {
    var result;
    $.ajax({
        url: "http://maps.googleapis.com/maps/api/geocode/json?address=" + location + "&components=country:UK&sensor=false&callback=?",
        async: false,
        data: 'json',
        dataType: 'text json',
        success: function (data) {
            result = data;
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status);
            alert(thrownError);
        }
    });

    return result;
}
Community
  • 1
  • 1
Liam
  • 9,725
  • 39
  • 111
  • 209
  • You're best off using the native geocoding methods provided in Google maps Api for javascript, that gets around all that sh*t. – Rob Schmuecker Jul 30 '14 at 14:43
  • Might not be the problem, but just an idea; jQuery has 2 versions. Version 1.x is designed to run on old browsers. Version 2.x does not work for IE 6, 7, or 8. See details on their download page. http://jquery.com/download/ – Bailey Herbert Jul 30 '14 at 14:46
  • No luck @BaileyHerbert thanks for the advice though – Liam Jul 30 '14 at 14:49
  • When you read it correctly somewhere(e.g. in the duplicate of this question/your previous question) then it should be clear that it's a browser-specific issue in jQuery which doesn't affect all browsers. – Dr.Molle Jul 30 '14 at 14:52
  • However, the geocoding-API did not specify the headers that will be sent, so you cant rely on the `access-control-allow-origin`-header. When no matching header will be sent(what happens often in the past) the request will fail in all browsers, so it's strongly recommended to use the geocoder of the Javascript-API as suggested by Rob Schmuecker. – Dr.Molle Jul 30 '14 at 15:04
  • async false for a x-domain request? uson json datatype and a jsonp url parameter? things look pretty messed up with this request. – Kevin B Jul 30 '14 at 15:18

0 Answers0