Home › Forums › JavaScript › Can this be executed more than once? › Re: Can this be executed more than once?
June 11, 2013 at 4:21 am
#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++;
}
});