简单的 JQuery getJSON 在 IE9 中不起作用

发布于 2024-11-28 08:01:30 字数 738 浏览 4 评论 0原文

我正在尝试从 SimpleGeo 中读取类别列表...我的代码在 Chrome 和 FireFox 中运行良好,但在 IE 中失败。

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

看看其他几篇文章似乎提供了一些想法,但 API 似乎没有提供回调,而且我无法控制它们的格式...

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

还有其他想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

划一舟意中人 2024-12-05 08:01:30

根据您引用的其中一个链接,似乎可能有解决方法。

尝试将 &format=jsonp&callback=? 添加到 URL。

我认为如果您添加回调参数,jQuery 可能会调用您指定的回调。

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.

稀香 2024-12-05 08:01:30

所以...事实证明,SimpleGeo 允许您通过其 javascript 客户端 API 获取类别列表。

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

棘手...

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

凉墨 2024-12-05 08:01:30

jQuery.support.cors = true;
就是这样

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文