ページを特定のポイント (#first_column DIV の高さ) までスクロールして、サーバー側から json を取得し、コンテンツを #first_column に追加します。
問題は、#first_column の高さまでスクロールすると、多くの Ajax 呼び出しがほぼ同時に発生することです。私が望むのは、#first_column の高さまでスクロールし、サーバーを呼び出して json データを取得し、コンテンツを #first_column に追加することです。#first_column の高さが変わります。次に、#first_column の高さまでスクロールすると、2 番目の Ajax リクエストが取得されます。
助言がありますか?
<script>
$(window).scroll(function(){
column_height = $("#first_column").height();
screenTop = $(window).scrollTop();
window_height = $(window).height();
if((screenTop+window_height)>=column_height){
$.ajax({
url: "/service/article_json.php",
type: 'GET',
async: false,
cache: false,
timeout: 30000,
error: function(){
return true;
},
success: function(data){
$.each($.parseJSON(data), function(key,item) {
//Add content to #first_column
});
}
});
}
});