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?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #45434


    I’ve written some simple jQuery to load an external html file when the user reaches the end of scroll. So far I’ve only been able to execute the function one time…allowing only one external file to load. I’m curious if anyone can suggest a method for calling the function each time the scroll reaches the bottom…thus loading a new external file each time.

    Here is what I have:

    $(window).scroll(function () {
    if ($(window).scrollTop() == $(document).height() – $(window).height()) {
    $.get(‘page2.html’).success(function (data) {

    Any help is appreciated. Thank you


    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) {

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.