title: jQuery AJAX-request loading twice
body: <p>I'm building an infinite Scroll which fetches results from a database when the scroller hits the bottom of the page. It's all working fine except for one small thing; it is fetching the results twice if I scroll down fast, as if the function is executed twice.</p>
  <p>Here is my jQuery code:</p>
  <pre><code>$(window).scroll(function () {
      if($(window).scrollTop() == $(document).height() - $(window).height()) {
          var ID = $('.stbody:last').attr('id').match(/stbody(\d+)/)[1];
          $('#loader').show();
          $.ajax({
              url: &quot;ajax_loadmore.php?lCom=&quot; + ID,
              success: function (result) {
                  if(result) {
                      $('#moreComments').append(result);
                      $('#loader').hide();
                  } else {
                      $('#loader').hide();
                  }
              }
          });
      }
  });
  </code></pre>