title: Auto Load content on scroll down using ajax
body: <p>I've built a application [php] that loads content like text &amp; images on scroll down automatically using ajax. The code works fine on <code>localhost</code>, but when i put it on my server it loads to slowly &amp; sometimes the page dows not load at all or even loads all the content at once. Is there any alternative so I can overcome this issue?</p>
  
  <p>Here's my code snippet that loads content from other page</p>
  
  <pre><code>$(document).ready(function(){
  var inc=5;
  $(window).scroll(function() {
      if ($('body').height()-190 &lt;= ($(window).height() + $(window).scrollTop())) {
      inc=inc+3;
          var dataString = inc;
          $.ajax({
              type: "POST",
              url: "two.php",
              data: {'limit': dataString},
              success: function(data) {
                  $('#a').html(data);
              }
          });
      }
  });
  });
  </code></pre>
  
  <p>Assume the image size to be 100kb &amp; the app loads 4-5 images on every scroll. Also the content comes from mysql databse through php &amp; also the "two.php" file contains all the data that is being fetched. The <code>limit</code> variable is just used to set a limit to mysql query, i.e. how many rows are to be returned.</p>