gpt4 book ai didi

javascript - jQuery/Tumblr - 解析 JSON 数据

转载 作者:行者123 更新时间:2023-11-30 13:26:22 25 4
gpt4 key购买 nike

我正在尝试通过 JSON API 读取 Tumblr 信息(并恢复博客的帖子总数)

我的 JS 代码如下所示:

 $.getJSON("http://demo.tumblr.com/api/read/json?callback=?", function(json) { 
$('.counter').html(json.posts-total);
});

但不起作用。

最佳答案

尝试:

$.getJSON("http://demo.tumblr.com/api/read/json?callback=?", function(json) { 
$('.counter').text(json["posts-total"]);
});

由于 - 是一个运算符,否则 JavaScript 会尝试从 json.posts 中减去 total

您可以在 this JSFiddle 中看到这个工作

关于javascript - jQuery/Tumblr - 解析 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8299309/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com