Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery/Tumblr-解析JSON数据_Javascript_Jquery_Json_Web Scraping_Tumblr - Fatal编程技术网

Javascript jQuery/Tumblr-解析JSON数据

Javascript jQuery/Tumblr-解析JSON数据,javascript,jquery,json,web-scraping,tumblr,Javascript,Jquery,Json,Web Scraping,Tumblr,我试图通过JSON API读取Tumblr信息(并恢复博客的帖子总数) 我的JS代码如下所示: $.getJSON("http://demo.tumblr.com/api/read/json?callback=?", function(json) { $('.counter').html(json.posts-total); }); 但是不起作用 不适用于tumblr,但使用jQuery获取json数据的更简单方法是 $.get( "http://demo.tumblr.com/

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

我的JS代码如下所示:

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

但是不起作用

不适用于tumblr,但使用jQuery获取json数据的更简单方法是

$.get( "http://demo.tumblr.com/api/read/json", {callback:"?"}, function(data){
    alert( data.posts-total )
}, "json");
也许另一种方法会有所帮助,而且firebug的控制台在了解ajax请求为何不起作用方面非常有效。也许也可以检查firebug->console

如果这些都不能帮助你回复更多的信息,你会发现还有什么可能是漏掉的。

试试:

$.getJSON("http://demo.tumblr.com/api/read/json?callback=?", function(json) { 
    $('.counter').text(json["posts-total"]);
});
由于
-
是一个运算符,否则JavaScript将尝试从
json.posts
中减去
total


你可以在

中看到这一点。我无法恢复帖子的总nb。这并没有发现问题,也没有解决问题。