I am calling ajax call but when I am scrolling 2 times its calling duplicate ajax calls.. For two scrolls I am getting duplicate ajax call.can anyone help me how to rectify duplicate ajax call.
jQuery(function($){
$('#infscr-loading').hide();
$(window).scroll(function() { //detect page scroll
if($(window).scrollTop() == $(document).height() - $(window).height()) {
var key = $(".tab-content div.active").attr("id");
var offset = $(".tab-content div.active .movie_boot .movie-beta__item").length;
var data1 = $("#yr").val();
url = "/loop-movies/?offset="+offset+'&key='+key+'&yr='+data1;
$.ajax({
type : "post",
url : url,
delay : 500,
beforeSend : function(){
$('#infscr-loading').show();
},
success : function(response) {
$(".tab-content div.active .movie_boot").append(response);
$('#infscr-loading').hide();
}
});
}
});
});