Simple JQuery getJSON is not working in IE9

2.2k Views Asked by At

I am trying to read in the category list from SimpleGeo... my code works fine in Chrome and FireFox, but fails in IE.

$.getJSON("http://api.simplegeo.com/1.0/features/categories.json",function(json){
    sgCategories = json;
});

Looking at a couple other posts seem to offer ideas but the API doesn't seem to offer a callback and I have no control of their format...

https://stackoverflow.com/questions/6514457/getjson-or-ajax-requests-not-working-with-ie9 https://stackoverflow.com/questions/3517608/why-isnt-this-simple-bit-of-jquery-getjson-working-in-ie8

Any other ideas?

3

There are 3 best solutions below

0
On BEST ANSWER

So... it turns out that SimpleGeo allows you to get the category list via their javascript client api.

var sgClient = new simplegeo.Client('yourAccessKey');
sgClient.getFeatureCategories(function(err, data) {
    if (err) {
        console.log(err);
    } else {
        sgCategories = data;
    };
});

Tricky...

0
On

jQuery.support.cors = true; that's it

1
On

Based on one of those links you have cited, it appears there may be a work around.

Try adding &format=jsonp&callback=? to the URL.

I think jQuery might call the callback you specify anyway if you add the callback parameter.