CrookedSpacesでタグ付けされた画像を要求するInstagramAPI呼び出しがあります。これらの画像が返されると、データをフィルタリングして、特定のユーザーからの画像のみを確認します(userIDを使用)。コードは次のとおりです。
$(function() {
$.ajax({
type: "GET",
dataType: "jsonp",
cache: false,
url: "https://api.instagram.com/v1/tags/crookedspaces/media/recent/?count=100&access_token=TOKEN",
success: function(data) {
for (var i = 0; i < 31; i++) {
var igUID = data.data[i].user.id;
if(igUID === "USER ID") {
$(".instagram").append("\
<div class='instagram-feed'>\
<img class='instagram-image' src='" + data.data[i].images.standard_resolution.url +"' width='325px' alt='" + data.data[i].user.id + " " + igUID + "' onMouseOver=\"toggle_visibility('igImageHover" + i + "');\"/>\
<div class='igHover' id='igImageHover" + i + "' onMouseOut=\"toggle_visibility('igImageHover" + i + "');\">\
<div class='igHover2'>\
SMALL TEST!\
</div />\
</div>\
</div>\
");
} else {
console.log("Else portion of code ran " + elseCount + " time(s).");
++elseCount;
}
}
}
});
});
ただし、その特定のユーザーIDによって投稿されていない画像が4つあるため、27の画像しか表示できません。forループを強制的にインクリメントしないようにする方法はありますか?または、コードを無限ループに送信せずにiから1を引くには?
これがJSFiddleです-http ://jsfiddle.net/UQcZP/