Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Can this be executed more than once? Re: Can this be executed more than once?

#138282
CrocoDillon
Participant

I don’t see why this doesn’t run more than once (loading the same content multiple times though). To fix the latter you can do something like:

var $window = $(window), // for efficiency
$document = $(document),
pages = ,
nextPage = 0;

$window.scroll(function () {
if (nextPage < pages.length &&
$window.scrollTop() == $document.height() – $window.height()) {
$.get(pages[nextPage]).success(function (data) {
$(‘#content’).append(data);
});
nextPage++;
}
});