JavaScriptを使用してギャラリーの画像を取得しようとしていますが、問題が発生します。
$(document).ready(function() {
var currentPage = 1;
var totalPics = 2;
var picPerPage = 1;
intervalID = window.setInterval(function() {
console.log(currentPage*picPerPage);
if (totalPics > (currentPage*picPerPage)) {
currentPage++;
fetchNextPage(currentPage);
} else {
clearInterval(intervalID);
}
}, 2000);
});
何らかの理由で、ループし続けます。その瞬間を止めてほしいcurrentPage * picPerPage > totalPics
。
私はubuntuでfirefox3.6.8を使用しています
アップデート
君たちありがとう。
この問題はfetchNextPage()関数が原因であることがわかりました。
コメントアウトすると、ループの問題は解決されます。
ただし、別の画像セットをフェッチするためにajax関数を実行するには、fetchNextPage関数が必要です。
以下は機能です
function fetchNextPage(currentPage) {
newUrl = currentUrl + currentPage;
$.ajax({
url: newUrl ,
success: function(data) {
// append page 2 themes
$('#themes-list').append(data);
}
});
}
無限のギャラリーが機能するようにするにはどうすればよいですか?
ありがとうございました。