title: infinite scrolling and reloading the appended data
body: <p>I have a web page in which I have infinite scrolling and it works well, but when the data appended after the infinite scrolling from the second page (say <code>scroling.php</code>) to the first page (say home page) is reloaded it just fades away. I mean that it gets displayed none.</p>
  
  <p>After spending hours I got to know that this is because when I try to reload any appended <code>div</code> the value of a variable (requested page) from the second page (<code>scrolling.php</code>) goes away.</p>
  
  <p>I think my code will make it clearer:</p>
  
  <pre><code>$(document).ready(function() {
      var page   = 1;
      var height = $("#forheight").height();
      $(window).scroll(function() {
          if ($(window).scrollTop() + height &gt;= $("#forscrilling").height()-10) {
              document.getElementById('infiscroll').style.display = 'block';
              page++;
              var data = {
                  requested_page: page,
                  listoffrndsinimplode: "&lt;?php echo $listoffrndsinimplode; ?&gt;"
              };
              var actual_count = "&lt;?php echo $noofposts; ?&gt;";
              if ((page-1)*13 &gt;= actual_count) {
                  document.getElementById('infiscroll').style.display='none';
              } else {
                  $.ajax({
                      type: "POST",
                      url: "scrolling.php",
                      data:data,
                      success: function(res) {
                          $("#loadinto").append(res);
                          document.getElementById('infiscroll').style.display='none';
                      }
                  });
              }
          }
      });
  });
  </code></pre>
  
  <p>This is on the first page for infinite scrolling and the code below is on the second page:</p>
  
  <pre><code>&lt;?php
  session_start();                            
  include_once('conn.php');
  $name = $_SESSION['name'];
  $id = $_SESSION['id'];
  $email = $_SESSION['email'];
  include_once('time.php');
  $requested_page = $_POST['requested_page'];
  $set_limit = (($requested_page - 1) * 13).",13";
  $listoffrndsinimplode = $_POST['listoffrndsinimplode'];
  $slashes = array("\'");
  $friendswithoutslashes = str_replace($slashes, "'", "$listoffrndsinimplode");
  $detailsoffrienda = mysql_query("
      select * from fk_views where (
          session_id IN ($friendswithoutslashes) or
          onprf_of IN ($friendswithoutslashes)) and
          (views !='' or uploadpic !='')
      order by id desc
      limit $set_limit
  ");
  ?&gt;
  </code></pre>
  
  <p>This is the code that I use for reloading the <code>div</code> using AJAX, which is on the first page:</p>
  
  <pre><code>function hits(obj) {
      var currentrateform = $(obj);
      var id = $(obj).attr("id"); //hitsform....
      $.ajax({
          type: 'POST',
          url: 'rating-manager.php', 
          data: currentrateform.serialize(),
          success: function(){
              $("#rate"+id).load("home.php #rate"+id);
          }
      });
      return false;
  }
  </code></pre>
  
  <p>Every <code>div</code> is given with a unique id, like rate + the id of the comment which is unique, so the id looks like <code>rate1,rate2,rate3</code>.</p>
  
  <p>I think when the value of the requested page gets away from the second page then there does not exist the id of the comment and so it just fades away as the page does not have any <code>div</code> with that id.</p>
  
  <p>I just want to ask how I can store the value of the requested page on second page. I cannot store it into sessions or cookies, as the requested page can be <code>2,3,4,5,6,7</code> -- any thing -- and I have many pages like this.</p>