title: Jquery infinite scroll loading all the time
body: <p>I can't see what i am doing wrong. But the code i use to load more images when scrolling won't work correctly. The ajax request works perfect, but i have big problems with the code loading images all the time when i just touch my scroll. I want it load new images when i get to the bottom of the page, not load everytime i touch the scroll.</p>
  
  <p>The code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(window).scroll(function() {
          if($(window).scrollTop() + $(window).height() &gt;= $(document).height() -300) {
  
              $('div#more').show();
              $.ajax({
                  url: "more.php?last=" + $('.fap:last').attr('id'),
                  success: function(html) {
                      if (html) {
                          $('#photos').append(html);
                          $('div#more').hide();
                      }
                      else {
                          $('div#more').replaceWith('&lt;center&gt;No more images&lt;/center&gt;')
                      }
                  }
              });
          }
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Any one knows how i can fix this?</p>