pagination with scroll using ajax

HTML PAGE IS HERE: IN CODEIGNITER::

<!DOCTYPE html>
<html lang="en">
 <head>
 <meta charset="utf-8">
 <title>Show More Testing</title>

 <style type="text/css">

 ::selection{ background-color: #E13300; color: white; }
 ::moz-selection{ background-color: #E13300; color: white; }
 ::webkit-selection{ background-color: #E13300; color: white; }

 body {
 background-color: #fff;
 margin: 40px;
 font: 13px/20px normal Helvetica, Arial, sans-serif;
 color: #4F5155;
 }

 a {
 color: #003399;
 background-color: transparent;
 font-weight: normal;
 }

 h1 {
 color: #444;
 background-color: transparent;
 border-bottom: 1px solid #D0D0D0;
 font-size: 19px;
 font-weight: normal;
 margin: 0 0 14px 0;
 padding: 14px 15px 10px 15px;
 }

 code {
 font-family: Consolas, Monaco, Courier New, Courier, monospace;
 font-size: 12px;
 background-color: #f9f9f9;
 border: 1px solid #D0D0D0;
 color: #002166;
 display: block;
 margin: 14px 0 14px 0;
 padding: 12px 10px 12px 10px;
 }

 #body{
 margin: 0 15px 0 15px;
 }

 p.footer{
 text-align: right;
 font-size: 11px;
 border-top: 1px solid #D0D0D0;
 line-height: 32px;
 padding: 0 10px 0 10px;
 margin: 20px 0 0 0;
 }

 #container{
 margin: 10px;
 border: 1px solid #D0D0D0;
 -webkit-box-shadow: 0 0 8px #D0D0D0;
 }
 
 .PROROW_CONTNR
 {
 border: 1px solid grey;
 margin-bottom: 6px;
 padding: 6px;
 box-sizing: border-box;
 background: white;
 }
 .span_SP12
 {
 border: 1px solid lightgrey;
 padding: 3px;
 margin-right: 10px; 
 }
 .PRO_FLEX1
 {
 background: #d3d3d3;
 padding: 5px;
 }
 .PRO_SHWNGMSG2
 {
 padding: 5px;
 text-align: center;

 }
 .SHWMORE_BTN
 {
 border: 1px solid grey;
 margin-bottom: 6px;
 padding: 6px;
 box-sizing: border-box;
 background: lightblue;
 width: 50%;
 margin-left: 25%;
 text-align: center;
 }
 ._SP12_MR11
 {
 font-size: 19px;
 cursor: pointer;
 padding: 5px;
 }
 </style>
 <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
 </head>
 <body>
 
 <script> 
    var GLOBAL_SXMR_XSNDRQST = true; 
    $(document).ready(function() 
    { 
       busy = false;
 
       $(window).scroll(function() 
       {
          if(GLOBAL_SXMR_XSNDRQST === true)
          {
             if ($(window).scrollTop() + $(window).height() >                    $("#PRO_MAIN_CONTER").height() && !busy ) 
 {
    busy = true;
    getscrld_prdctnow();
 }
 }
 });
 
 
 });
 
 
 var GLOBAL_SXMR_XPRODID = 0;
 var GLOBAL_SXMR_XLASTCNT = 0;
 var GLOBAL_SXMR_XTOTPROD = 0;
 function getscrld_prdctnow()
 {
 
 $.ajax({
 url:'http://localhost/sharma/showmorescroll/scroll-getmoredata',
 type: 'POST',
 data:{'LID':GLOBAL_SXMR_XPRODID,'LCNT':GLOBAL_SXMR_XLASTCNT,'TPROD':GLOBAL_SXMR_XTOTPROD},
 success:function(html){
 //alert (data);
 $("._XzscrlMr_PDZ99").remove();
 $("#PRO_MAIN_CONTER").append(html);
 busy = false;
 window.busy = false;
 },
 error: function () {
 //alert('Some error');
 }
 });
 }
 </script>
 
 <div id="container">
 <h1 style="text-align:center; ">TESTING</h1>
 <div id="body">
 <div class="PRO_MAIN_CONTER" id="PRO_MAIN_CONTER">
 
 <div class="PRO_FLEX1" id="PRO_FLEX1">
 <?php
 $SHMOR_COUNT = 1;
 $SHMOR_TMP_UPTO_ROW = 0;
 $SHMOR_LAST_PROD_ID = 0;
 if($FOUND)
 {
 foreach($PRODUCTS as $DBPRO)
 {
 $product_id = $DBPRO['product_id'];
 $product_title = $DBPRO['product_title'];
 $product_price = $DBPRO['product_price'];
 $product_slug = $DBPRO['product_slug'];
 $SHMOR_LAST_PROD_ID = $product_id;
 $SHMOR_COUNT++;
 ?>
 <div class="PROROW_CONTNR">
 <span class="span_SP12"> SL NO: <?php echo $product_id;?></span>
 <span><?php echo $product_slug;?></span>
 </div>

 <?php
 }
 $SHMOR_TMP_UPTO_ROW = $SHMOR_COUNT-1;
 }
 ?>
 
 </div>
 <div class="PRO_SHWNGMSG2 ">Showing Products Upto <?php echo $SHMOR_TMP_UPTO_ROW;?> in <?php echo $TOTAL_PRODUCTS;?></div> 
 <input type="hidden" name="" class="_XzscrlMr_PDZ99" id="MOREAFTR-<?php echo $SHMOR_LAST_PROD_ID;?>" data-moreaftr="<?php echo $SHMOR_LAST_PROD_ID;?>" data-lstcnt="<?php echo $SHMOR_COUNT;?>" >

 <script>
 var GLOBAL_SXMR_XTOTPROD = <?php echo $TOTAL_PRODUCTS;?>;
 var GLOBAL_SXMR_XPRODID = <?php echo $SHMOR_LAST_PROD_ID;?>;
 var GLOBAL_SXMR_XLASTCNT = <?php echo $SHMOR_COUNT;?>;
 var GLOBAL_SXMR_XSNDRQST = true;
 </script>
 </div>
 </div>

 </div>
 </body>
</html>
In the Controller:
<?PHP

class Scrollmore extends CI_Controller 
{ 
 public function index()
 {
 $this->db->select("*");
 $this->db->from("td_product");
 $this->db->order_by('product_id', 'ASC');
 $this->db->limit(15); 
 $SHR14_GETPRO_QU = $this->db->get();
 $SHR14_GETPRO_RES_ROW = $SHR14_GETPRO_QU->num_rows();
 $SHR14_GETPRO_RES = $SHR14_GETPRO_QU->result_array();

 
 // USED TO GET TOTAL PRODUCTS 
 $this->db->select("*");
 $this->db->from("td_product");
 $this->db->order_by('product_id', 'ASC'); 
 $SHR15_GETPRO_QU = $this->db->get();
 $SHR15_GETPRO_RES_ROW = $SHR15_GETPRO_QU->num_rows();
 
 
 $PASSING_ARR = array();
 $PASSING_ARR['TOTAL_PRODUCTS'] = $SHR15_GETPRO_RES_ROW;
 
 $PASSING_ARR['FOUND'] = $SHR14_GETPRO_RES_ROW;
 
 $PASSING_ARR['PRODUCTS'] = $SHR14_GETPRO_RES;
 $this->load->view('scrollmore_main',$PASSING_ARR);
 }
 
 public function getby_scrollmore()
 {
 $GOT_LAST_PID = $_POST['LID'];
 $GOT_LAST_ROW = $_POST['LCNT'];
 $GOT_TOTAL_PROD = $_POST['TPROD'];
 $GOT_LAST_ROWPLUS = $GOT_LAST_ROW;
 
 $this->db->select("*");
 $this->db->from("td_product");
 $this->db->where("product_id > $GOT_LAST_PID");
 $this->db->order_by('product_id', 'ASC');
 $this->db->limit(10);
 $SHR14_GETPRO_QU = $this->db->get();
 $SHR14_GETPRO_RES_ROW = $SHR14_GETPRO_QU->num_rows();
 $SHR14_GETPRO_RES = $SHR14_GETPRO_QU->result_array();
 
 $SHMOR_COUNT = $GOT_LAST_ROW;
 $GOT_UPTO_ROW = 0;
 $SHMOR_LAST_PROD_ID = 0;
 if($SHR14_GETPRO_RES_ROW)
 {
 ?>
 <div class="PRO_FLEX1">
 <?php

 foreach($SHR14_GETPRO_RES as $DBPRO)
 {
 $product_id = $DBPRO['product_id'];
 $product_title = $DBPRO['product_title'];
 $product_price = $DBPRO['product_price'];
 $product_slug = $DBPRO['product_slug'];
 $SHMOR_LAST_PROD_ID = $product_id;
 $SHMOR_COUNT++;
 ?>
 <div class="PROROW_CONTNR">
 <span class="span_SP12"> SL NO: <?php echo $product_id;?></span>
 <span><?php echo $product_slug;?></span>
 </div>

 <?php
 }
 $GOT_UPTO_ROW = $SHMOR_COUNT-1;
 ?>

 </div>
 <div class="PRO_SHWNGMSG2">Showing Products From <?php echo $GOT_LAST_ROWPLUS; ?> Upto <?php echo $GOT_UPTO_ROW;?> in <?php echo $GOT_TOTAL_PROD;?></div> 
 <input type="hidden" name="" class="_XzscrlMr_PDZ99" id="MOREAFTR-<?php echo $SHMOR_LAST_PROD_ID;?>" data-moreaftr="<?php echo $SHMOR_LAST_PROD_ID;?>" data-lstcnt="<?php echo $SHMOR_COUNT;?>" >
 <script> 
 var GLOBAL_SXMR_XTOTPROD = <?php echo $GOT_TOTAL_PROD;?>;
 var GLOBAL_SXMR_XPRODID = <?php echo $SHMOR_LAST_PROD_ID;?>;
 var GLOBAL_SXMR_XLASTCNT = <?php echo $SHMOR_COUNT;?>;
 var GLOBAL_SXMR_XSNDRQST = true;
 </script>
 <?php
 }
 else
 {
 ?>
 <div class="PRO_SHWNGMSG2">Currently No More Products</div>
 <script> 
 var GLOBAL_SXMR_XSNDRQST = false;
 </script> 
 
 <?php 
 }
 }
}
?>

ROUTES:
$route['default_controller'] = "scrollmore";
$route['scroll-getmoredata'] = "scrollmore/getby_scrollmore";