Есть функция, выполняюшая ajax запрос. После выполнения выставляются новые параметры для следующего ajax запроса.
Вопрос: как не дать выполниться функции ещё раз, пока совершается ajax запрос? Вся проблема в том, что если быстро запускать событие с запросом, то новые параметры не успевают установиться.
Вот код:
var next_cursor = '';
var count = 0;
$.getJSON(
"https://api.instagram.com/v1/users/self/followed-by?access_token=<?php echo $_COOKIE['instaphp'];?>&cursor="
+ next_cursor
+ "&callback=?",
function(data){
$.each(
data.data,
function(i,item){
$("<li></li>").html('<s>' + item.username + '</s>').appendTo("#list_fol");
}
);
next_cursor = data.pagination.next_cursor;
}
);
$(document).scroll(
function(){
if( $(document).height() - $(window).height() - 300 <= $(document).scrollTop()) {
$.getJSON(
"https://api.instagram.com/v1/users/self/followed-by?access_token=<?php echo $_COOKIE['instaphp'];?>&cursor="
+ next_cursor
+ "&callback=?",
function(data){
$.each(
data.data,
function(i,item){
$("<li></li>").html('<s>' + item.username + '</s>').appendTo("#list_fol");
count++;
}
);
next_cursor = data.pagination.next_cursor;
}
);
}
}
);