title: Javascript Load More Data on Click in Codeigniter results not displaying
body: <p>I have products in table I wish to display some when page load and remain data should display on button click, I have set limit as 6 per page, when page loading it is displaying first six rows and if I click on Load More button it is displaying another six rows here problem coming after got 12 rows from table when I click again on Load More button it is not working even I have more data in table, I have cross checked parameters also, it is fine parameters also sending with request. please help me how to solve this.</p>
  
  <p>NOTE: when I test this script in core php it is working fine, when I implement this script in codeigniter first time click load more data working second time when i click it is not wokring.</p>
  
  <p>Javascript Code Block</p>
  
  <pre><code>$('.more').click(function(){
  var ID = $(this).attr("id");
  var cats = $('input[name=cats]').val();
  $("#more"+ID).html('&lt;img src="&lt;?=ROOT;?&gt;resources/moreajax.gif" /&gt;');
  $.post('&lt;?=ROOT;?&gt;product/dataLoad', {id:ID,cats:cats}, function(data){
      if(data)
      {
      $('ol#updates').append(data);
      $("#more"+ID).remove();
          }
      else
      {
      $(".morebox").html('The End');// no results
      }
  
  });
  return false;
  });
  </code></pre>
  
  <p>codeigniter controller function</p>
  
  <pre><code>public function dataLoad() {
          if(isset($_POST['id']))
          {
          $lastmsg=$_POST['id'];
          $cats = $_POST['cats'];
          $query=mysql_query("select * from product where id &gt; '".$lastmsg."' AND category_id IN ($cats) order by id asc limit 4");
          $numrows = mysql_num_rows($query);
          while($ob = mysql_fetch_array($query))
          {
          ?&gt;
          &lt;div&gt;
          &lt;p&gt;ID: &lt;?=$ob['id']; &lt;/p&gt;
          &lt;p&gt;NAME: &lt;?=$ob['name']; &lt;/p&gt;
          &lt;/div&gt;
          &lt;?php
          }//while
          ?&gt;
          &lt;?php
          if($numrows &gt; 0)
          {
          ?&gt;
          &lt;div id="more&lt;?php echo $ob['id']; ?&gt;" class="morebox" style="clear:both"&gt;
          &lt;input type="hidden" name="cats" value="&lt;?=$cats;?&gt;" /&gt;
          &lt;a href="#" class="more" id="&lt;?=$ob['id'];?&gt;"&gt;Load More&lt;/a&gt;
          &lt;/div&gt;
          &lt;?php
          }
  
       }
          ?&gt;
  </code></pre>
  
  <p>product page code</p>
  
  <pre><code>&lt;ol class="timeline" id="updates"&gt;
      $str = implode(",",$cats);
              $query = "select * FROM product WHERE category_id IN (".$str.")         order by id asc limit 4";
              $result=mysql_query($query);
              $numrows = mysql_num_rows($result);
              while($ob = mysql_fetch_array($result))
              {
              ?&gt;
              &lt;div&gt;
              &lt;p&gt;ID: &lt;?=$ob['id']; &lt;/p&gt;
              &lt;p&gt;NAME: &lt;?=$ob['name']; &lt;/p&gt;
              &lt;/div&gt;
              &lt;?php
              }//while
              ?&gt;
      &lt;/ol&gt;
              &lt;?php
              if($numrows &gt; 0)
              {
              ?&gt;
              &lt;div id="more&lt;?php echo $ob['id']; ?&gt;" class="morebox" style="clear:both"&gt;
              &lt;input type="hidden" name="cats" value="&lt;?=$cats;?&gt;" /&gt;
              &lt;a href="#" class="more" id="&lt;?=$ob['id'];?&gt;"&gt;Load More&lt;/a&gt;
              &lt;/div&gt;
              &lt;?php
              }
              ?&gt;
  </code></pre>