0
我在我的網站上有一系列Tumblr訂閱源,每個訂閱源都從不同的標籤中檢索帖子。Tumblr API'Uncaught TypeError:無法讀取屬性'type'undefined'
第一饋腳本工作,但第二和第三拋出錯誤:
Uncaught TypeError: Cannot read property 'type' of undefined
每個腳本如出一轍接受的標籤檢索和元素被添加到數據。
我很難解決這個問題。有誰知道我做錯了什麼?
$.ajax({
url: "http://api.tumblr.com/v2/blog/myblog.tumblr.com/posts?api_key=mykey&tag=news",
dataType: 'jsonp',
success: function(results){
var i = 0;
while (i < 10) {
var type = results.response.posts[i].type;
var date = results.response.posts[i].date;
var link = results.response.posts[i].post_url;
if (type == "text") {
var title = results.response.posts[i].title;
var content = results.response.posts[i].body;
$("#tumnews #newscara").append("<div class='tumpost'><a href='" + link + "'><h2>" + title + "</h2>" + content + "</a></div>");
}
else if (type == "photo") {
var photourl = results.response.posts[i].photos[0].alt_sizes[0].url;
$("#tumnews #newscara").append("<li><div class='tumpost'><a href='" + link + "'><img src='" + photourl + "' alt='" + title + "'/></a></div></li>");
}
i++;
}//END WHILE
$("#newscara").flexisel({
visibleItems: 5,
animationSpeed: 200,
autoPlay: true,
autoPlaySpeed: 3000,
pauseOnHover: true,
clone:false,
});
}//END RESULTS FUNCTION
});
乾杯,@ MeltingDog這只是幫助我。 – lharby