使用 jQuery 和 JSON REST 方法附加 StumbleUpon url 视图无效标签问题

发布于 2024-10-05 20:37:50 字数 1545 浏览 0 评论 0原文

我读过很多关于这个的文章,但我就是不明白。它与我的代码无关。我尝试从 StumbleUpon Badges 获取 json 数据。正如他们的文件:

徽章 API 允许网站发布者通过查询徽章所在页面的信息,在其页面上创建自定义 StumbleUpon 徽章。这是通过一个简单的 REST API 提供的,输出为 JSON 格式。 当前版本:1.01 默认版本:1.01

,我的代码是:

    jQuery.getJSON('http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://www.narga.net/',
        function(data) {
            jQuery('.stumbleupon').html(data.encoding);
    });

Firefox错误控制台输出

Error: invalid label源文件:http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://www.narga.net/&c=jsonp1291473203053 <代码>行:1,列:1 来源: `{"result":{"url":"http://www.narga.net/","in_index":true,"publicid":"1DXaNI","views":921,"title":"Narga - 我认为的想法和灵感! ","thumbnail":"http://cdn.stumble-upon.com/altmthumb/271/17122271.jpg","thumbnail_b":"http:

//cdn.stumbleUpon当我添加 &callback 或不添加 &callback 时,徽章 JSON 输出差异。如果我不添加 &callback 并将警报(数据)添加到函数(数据)中,则 Firefox 错误控制台会告诉我 dat 为空。 如何获取 StumbleUpon Badges JSON 的视图值,然后将其附加到

<a href="link" class="stumble">stumble</a>

我尝试过的

    jQuery.getJSON('http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://www.narga.net/',  
    function(data) {
        jQuery('.stumbleupon').html(data.result.views); 
    });

但它不起作用,我仍然收到无效标签错误

I've read about this a lot and I just can't figure it out. It has nothing to do with MY code. I've tried to get the json data from StumbleUpon Badges. As their documents:

The Badge API allows web site publishers to create custom StumbleUpon badges on their pages by querying information about the page which the badge sits on. This is provided through a simple REST API with output in JSON format.
Current Version: 1.01
Default Version: 1.01

and my code is:

    jQuery.getJSON('http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://www.narga.net/',
        function(data) {
            jQuery('.stumbleupon').html(data.encoding);
    });

the Firefox error console output

Error: invalid label
Source file: http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://www.narga.net/&c=jsonp1291473203053
line: 1, colume: 1
Source:
`{"result":{"url":"http://www.narga.net/","in_index":true,"publicid":"1DXaNI","views":921,"title":"Narga - Ideas and inspiration in my opinion! ","thumbnail":"http://cdn.stumble-upon.com/altmthumb/271/17122271.jpg","thumbnail_b":"http://cdn.stumb

the StumbleUpon Badge JSON output difference when I add &callback or not. If I not add &callback and add alert(data) into function (data) then the Firefox Error Console tell me the dat is null.
How can I get the views value of StumbleUpon Badges JSON then append it into

<a href="link" class="stumble">stumble</a>

I've tried with

    jQuery.getJSON('http://www.stumbleupon.com/services/1.01/badge.getinfo?url=http://www.narga.net/',  
    function(data) {
        jQuery('.stumbleupon').html(data.result.views); 
    });

but it's not works, I still get invalid label error

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文