title: load content by ajax when scroll reach to bottom
body: <p>i am so tired of this and i found no solution for this until now.here is my code</p>
  
  <pre><code>$("#submit").click(function(e){
      e.preventDefault()  
      var loading = "&lt;img src='/zojfa/images/loading.gif' alt='Loading...' /&gt;";
      var scrolltop=$('#scrollbox').attr('scrollTop');
      var scrollheight=$('#scrollbox').attr('scrollHeight');
      var windowheight=$('#scrollbox').attr('clientHeight');
      var post = $(this).attr("name") + "=" + $(this).val();
      var form_data = $('#search_form').serialize() + "&amp;" + post;
  
      var scrolloffset=20;
      $('#search').html(loading);
      $.post("dosearch.php",form_data,function(newitems) {
          $('#content').append(newitems);
              });
      $('#scrollbox').scroll(function(){
      if(scrolltop&gt;=(scrollheight-(windowheight+scrolloffset))){
          form_data = form_data + "&amp;size=" + $("#content &gt; div").size();
      setTimeout($.post("dosearch.php",form_data,function(newitems) {
          $('#content').append(newitems);
              }),5000);
      }
      });     
          });
  
  });
  </code></pre>
  
  <p>when i post form data this form data will serialize() and send to dosearch.php.</p>
  
  <p>the function work well when i click on submit button function will execute and give me the result set which is line 11 of this script.</p>
  
  <p>then i will listen to scroll event, when scroll event will happen i'll count the div's inside my content div to know how many div i have loaded until now and send this number to dosearch to get more result </p>
  
  <p>SELECT something FROM table WHERE someid=some another id LIMIT $number(which i get from counting divs.. is there another solution?maybe set id for divs?is this solution that i use good enough?),6</p>
  
  <p>now where is my problem.i check posted data by firebug</p>
  
  <p>and when i reach the bottom of this div many ajax request fire up.and shows many posted size with diffrent value like this in firebug console</p>
  
  <pre><code>size=6
  size=12
  size=12
  </code></pre>
  
  <p>i thought about settimeout maybe fix my script but gain no success in this.</p>
  
  <p>I appreciate your help.</p>