title: Need a ajax pagination in codeigniter
body: <p>I am having a view in codeigniter where i have used codeigniter pagination method. I need to load the pagination via ajax so that my page will not change..</p>
  
  <p>Currently my url is like this for first page.
  <a href="http://192.168.1.60/dream1/testimonial" rel="nofollow">http://192.168.1.60/dream1/testimonial</a></p>
  
  <p>Once i enters to next page it change the url to <a href="http://192.168.1.60/dream1/testimonial/page/2" rel="nofollow">http://192.168.1.60/dream1/testimonial/page/2</a></p>
  
  <p>What i require is to load the pagination from same url even if i change the page</p>
  
  <p>This is my controller:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  if (!defined('BASEPATH'))
      exit('No direct script access allowed');
  
  class testimonial extends CI_Controller {
  
      public function __construct() {
          parent::__construct();
  
          
           $this-&gt;load-&gt;model('testimonials_model','obj_testimonials',TRUE);
      }
      
      public function index() {
          $row=0;
  //        $limit='2';
          $this-&gt;load-&gt;library('pagination');
          $config = $this-&gt;get_pagination_config();
          $this-&gt;pagination-&gt;initialize($config);
          $data['links'] = $this-&gt;pagination-&gt;create_links();
          $data['testimonials']=$this-&gt;obj_testimonials-&gt;get_all_entries($row,$lim=2,$condition=array(),'testimonials_display_order','');
          $this-&gt;load-&gt;view('web/testimonials',$data);
      }
      public function page($page_number=1) 
      {
          $this-&gt;load-&gt;library('pagination');
          $pagination_config = $this-&gt;get_pagination_config();
          
          $per_page = 1;
          $row= $page_number * $per_page - $per_page;
          $limit = $pagination_config["per_page"];
  
          $this-&gt;pagination-&gt;initialize($pagination_config);
          $data['links'] = $this-&gt;pagination-&gt;create_links();
          $data['testimonials']=$this-&gt;obj_testimonials-&gt;get_all_entries($row,$lim=2,$condition=array(),'testimonials_display_order','');
          $this-&gt;load-&gt;view('web/testimonials',$data);
      }
      
      public function get_pagination_config()
      {
          $config['base_url'] = site_url() . '/testimonial/page';
          $config['full_tag_open'] = '&lt;li&gt;';
          $config['full_tag_close'] = '&lt;/li&gt;';
          $config['uri_segment'] = 3;
          $config['total_rows'] = $this-&gt;obj_testimonials-&gt;countrows();
          $config['per_page'] = 2;
          return $config;
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>(I have used no if items to display per page as two)</p>
  
  <p>My vie page is this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
          &lt;link type="image/png" rel="shortcut icon" href="&lt;?= base_url() ?&gt;images/fav.png"/&gt;
          &lt;link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400,600' rel='stylesheet' type='text/css'&gt;
              &lt;title&gt;Kerala Tourism Places | kerala Tour Packages Review&lt;/title&gt;
  
  &lt;meta name="description" content="Here are the testimonials given by travel lovers about thier Kerala holidays, our Honeymoon Packages and holiday packages."&gt;
  
  &lt;meta name="keywords" content="Kerala Tourism Places, kerala Tour Packages Review, kerala Tour Packages"&gt;
  &lt;meta http-equiv="Content-Language" content="en-us" /&gt;
  &lt;meta name="author" content="Dreamholidays Kerala" /&gt;
  &lt;meta http-equiv="Robots" content="index,follow,all" /&gt;
  &lt;meta name="GOOGLEBOT" content="index,follow,all" /&gt;
  &lt;link rel="canonical" href="http://dreamholidayskerala.com/testimonials.php" /&gt;
  &lt;base href="http://dreamholidayskerala.com" /&gt;
  &lt;meta name="copyright" content="dreamholidayskerala.com"&gt;
              &lt;link href="&lt;?= base_url() ?&gt;css/style.css" rel="stylesheet" type="text/css" /&gt;
              &lt;link rel="stylesheet" href="&lt;?= base_url() ?&gt;fonts/font.css"&gt;
                  &lt;link rel="stylesheet" type="text/css" href="&lt;?= base_url() ?&gt;css/style_common.css" /&gt;
                  &lt;link rel="stylesheet" type="text/css" href="&lt;?= base_url() ?&gt;css/style5.css" /&gt;
                  &lt;link rel="stylesheet" type="text/css" href="&lt;?= base_url() ?&gt;css/jquery.fancybox.css?v=2.1.5" media="screen" /&gt;
                  &lt;script type="text/javascript" src="&lt;?= base_url() ?&gt;js/jquery-1.10.1.min.js"&gt;&lt;/script&gt;
                  &lt;script type="text/javascript" src="&lt;?= base_url() ?&gt;js/jquery.fancybox.js?v=2.1.5"&gt;&lt;/script&gt;
                  &lt;script type="text/javascript"&gt;
                      $(document).ready(function () {
  
                          $('.fancybox').fancybox();
  
  
                      });
                  &lt;/script&gt;
                  &lt;/head&gt;
                  &lt;body&gt;
                      &lt;div id="wrapper"&gt;
                          &lt;!--banner starts here--&gt;
                          &lt;div class="sub-banner-wrapper"&gt;
                              &lt;div class="sub-banner"&gt; &lt;img src="&lt;?= base_url() ?&gt;images/sub-banner-4.jpg" /&gt; &lt;/div&gt;
                              &lt;div class="transperant-layer"&gt;
                                  &lt;div class="sub-banner-captions"&gt;
                                      &lt;h2&gt;Words fuelling us to &lt;span&gt;serve better!&lt;/span&gt;&lt;/h2&gt;
                                       &lt;p&gt;See comments from our esteemed clients that testifies our excellence, professionalism and commitment. &lt;/p&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;!--banner ends here--&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                      &lt;div class="contentarea-main"&gt;
                          &lt;div class="content-area-inner"&gt;
                              &lt;div class="destination-main"&gt;
                                  &lt;!--destinations introduction starts here--&gt;
                                  &lt;div class="destination-introduction"&gt;
                                      &lt;div class="destination-heading"&gt;
                                          &lt;h1&gt;Our &lt;span&gt; Testimonials &lt;/span&gt;&lt;/h1&gt;
                                      &lt;/div&gt;
                                      &lt;div class="clear"&gt;&lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="testimonials-page-main"&gt;
                                          
                                      &lt;div class="testimonials-box-area" id="containerid"&gt;
                                          &lt;?php $i=0;foreach($testimonials as $test){?&gt;
                                          &lt;div class="&lt;?php if($i%2 == 0){echo 'testi-client';}else{echo 'testi-client no-right-margin';}?&gt;"&gt;
                                              &lt;?php if(!empty($test['testimonials_image'])){?&gt;
                                              &lt;div class="testi-blue-bg"&gt;
                                                  &lt;div class="client-round"&gt;&lt;img src="&lt;?= base_url()?&gt;uploads/testimonials/thumb/&lt;?= $test['testimonials_image']?&gt;" /&gt;&lt;/div&gt;
                                              &lt;/div&gt;
                                              &lt;div class="client-note"&gt;
                                                  &lt;p&gt;&lt;?= word_limiter($test['testimonials_content'],62);?&gt;&lt;/p&gt;
                                                  &lt;p&gt;&lt;span&gt;&lt;?= $test['testimonials_name'];?&gt;,&lt;/span&gt; &lt;?= $test['testimonials_title'];?&gt;&lt;/p&gt;
                                              &lt;/div&gt;
                                              &lt;?php }else{?&gt;
                                              &lt;div class="client-note"&gt;
                                                  &lt;p style="width: 440px;"&gt;&lt;?= word_limiter($test['testimonials_content'],62);?&gt;&lt;/p&gt;
                                                  &lt;p&gt;&lt;span&gt;&lt;?= $test['testimonials_name'];?&gt;,&lt;/span&gt; &lt;?= $test['testimonials_title'];?&gt;&lt;/p&gt;
                                              &lt;/div&gt;
                                              &lt;?php }?&gt;
                                          &lt;/div&gt;
                                              
                                          &lt;?php $i++;}?&gt;
                                      &lt;/div&gt;
  
                                  &lt;/div&gt;
                                  &lt;div class="pagenintaion-counter"&gt;
                                      &lt;ul id="pagination-div-id"&gt;
                                          &lt;?php echo $this-&gt;pagination-&gt;create_links();?&gt;
                                      &lt;/ul&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="clear"&gt;&lt;/div&gt;
                              &lt;div class="clear"&gt;&lt;/div&gt;
                              &lt;div class="clear"&gt;&lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="clear"&gt;&lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/body&gt;
                  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can anyone help me on this...</p>
  
  <p>Thank you..</p>