title: infinite scrolling using jQuery
body: <p>The script is working fine, but when the content ends, the page never reaches to the end. I need to make it stop infinite scrolling when the loaded content is end.</p>
  
  <p>Another question, i dont want to load all the divs right away, i need to load it every five in five, how can i do that?</p>
  
  <p>js:</p>
  
  <pre><code>if($(window).scrollTop() == $(document).height() - $(window).height())
      {
          $('div#loadmoreajaxloader').show();
          $.ajax({
          url: "loadmore.php",
          success: function(html)
          {
              if(html)
              {
                  $("#postswrapper").append(html);
                  $('div#loadmoreajaxloader').hide();
              }else
              {
                  $('div#loadmoreajaxloader').html('&lt;center&gt;No more posts to show.&lt;/center&gt;');
              }
          }
          });
      }
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;div id="postswrapper"&gt;
     &lt;div class="item"&gt;content&lt;/div&gt;
     ...
     &lt;div id="loadmoreajaxloader" style="display:none;"&gt;&lt;center&gt;&lt;img src="bigLoader.gif" /&gt;&lt;/center&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and the loadmore.php contains many <code>&lt;div class="item"&gt;content&lt;/div&gt;</code></p>