1

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?

Community
  • 1
  • 1
mmartimo
  • 121
  • 4
  • Looks like a cross-domain request. Perhaps IE doesn't support cross-domain requests? – beatgammit Aug 07 '11 at 12:26
  • I cannot check with api doc now, but isn't second arg in that func data to post? Try add null as second arg, I'm probably wrong but it is a few seconds check – Goran Obradovic Aug 07 '11 at 12:33

3 Answers3

1

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.

Mike Thomsen
  • 36,828
  • 10
  • 60
  • 83
  • Unfortunately, adding either or both causes it to fail in all browsers... it seems they aren't supported by the SimpleGeo API. Trying to find a work around... vexing as it works great in all but IE and I can easily see the data by going to: [http://api.simplegeo.com/1.0/features/categories.json](http://api.simplegeo.com/1.0/features/categories.json) – mmartimo Aug 07 '11 at 14:28
1

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...

mmartimo
  • 121
  • 4
1

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

Evgeniy
  • 555
  • 7
  • 26