I need help in this matter. Now I'm studying lazy loading. And the endless scrolling turned out to be done. And in general, the code works, the content gives. But I can't figure out how to redo it so that it gives away 10 elements of, say, div's that are on the way to the URL, and if they ended there, then it would stop immersing the content of these div's. It seems to count, but I don't understand what to do with it. Maybe there was a similar topic, but I didn't find something.
function loadPageAjax(getSectionNumbers) {
$.ajax({
url: "lazy-page.html",
type: "GET",
data: { getSectionNumbers: getSectionNumbers },
onSubmit: function ajaxViewsLoader() {
$(".loading-icon").fadeIn();
},
success: function ajaxViewsSection(data) {
$(".loading-icon").fadeOut();
// Здесь мы получаем данные, отправленные сервером и выводим
$(".load-wrapp").append(data);
sectionNumber++;
console.log(getSectionNumbers);
}
});
getHeightContent = $(".load-wrapp").outerHeight();
}
$(window).scroll(function () {
if ($(this).scrollTop() >= getHeightContent - 5) {
loadPageAjax(sectionNumber);
}
});