title: check if the user has reached to bottom of the page
body: <p>I am trying to trigger an event when the users scrolls down and reaches to the bottom of the page.</p>
  
  <p>I searched the internet and found some posts in stackoverflow but unexpectedly the answers did not work for me.</p>
  
  <p>Ex: <a href="https://stackoverflow.com/questions/3898130">Check if a user has scrolled to the bottom</a></p>
  
  <p>using the answers given for the above SO post, the event I am trying to trigger is executed when reaching the top of the page and not the bottom.</p>
  
  <p>Please let me know if I am going wrong:</p>
  
  <pre><code>$(window).scroll(function() {
  if($(window).scrollTop() + $(window).height() == $(document).height()) {
     loadmore();
  }
  });
  
  function loadmore(){
  
  var lastProd = $('.product_div').last(); 
  var lastProdID = $('.product_div').last().prop('id'); 
  //console.info(lastProdID); return false;
  //var val = document.getElementById("row_no").value;
  $.ajax({
      type: 'post',
      url: 'includes/load_products.php',
      data: { getresult:lastProdID },
      success: function (response) {
          console.log(response);
          //var content = document.getElementById("all_rows");
          //content.innerHTML = content.innerHTML+response;
          lastProd.after(response);
  
          // We increase the value by 10 because we limit the results by 10
          // document.getElementById("row_no").value = Number(val)+10;
      }
  });
  }
  </code></pre>