Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

Stop requests when all content loaded #3

Open
creativetags opened this issue Feb 27, 2013 · 1 comment
Open

Stop requests when all content loaded #3

creativetags opened this issue Feb 27, 2013 · 1 comment

Comments

@creativetags
Copy link

How would you change this so it didn't keep sending requests as the user scrolls down when all the content is already loaded?

@creativetags
Copy link
Author

In answer to my own question:

I found this comment led me to change the javascript on the index page to:

  if(nearBottomOfPage()) {
    loading=true;
    page++;
    $.ajax({
      url: '/articles?page=' + page,
      type: 'get',
      dataType: 'script',
      success: function(response) {
        if (response != "$(\"#articles\").append(\"<div class='page'></div>\");") {
          loading=false;
        }
      }
    });

So when it gets to the end the loading variable is never set to false so it stops making requests as if it were still waiting on an existing one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant