Hello, I'm going to make ajax pagination using codeigniter .. I tried the code, but it seems that pagination does not change the active link. please help .. here is my ajax
$(function() {
applyPagination();
function applyPagination() {
$("#paging a").click(function() {
var url = $(this).attr("href");
$.ajax({
type: "POST",
data: "ajax=1",
url: url,
beforeSend: function() {
$("#things").html("");
},
success: function(msg) {
$("#things").html(msg);
applyPagination();
}
});
return false;
});
}
});
another ajax code i tried
<script>
$(document).ready(function(){
$("#paging a").click(function()
{
var this_url = $(this).attr("href");
$.post(this_url,{ },function(data){
$("div#things").html(data);
});
return false;
});
});
my view pagination id
<div class="paging" id="paging">
<aside>
<?php echo $links; ?>
</aside>
</div>
My controller
public function index($start_row="")
{
$start_row = $this->uri->segment(4);
$per_page=5;
if(trim($start_row) == '')
{
$start_row = 0;
}
$result = $this->abouthistory_model->history_list();
$data["CatId"]=$this->viewbook_model->getCategory();
$total_rows=count($result);
$this->load->library('pagination');
$config['uri_segment'] = 4;
$config['base_url'] = base_url()."about/abouthistory/index";
$config['total_rows'] = $total_rows;
$config['per_page'] =$per_page;
$config['is_ajax_paging'] = TRUE;
$config['paging_function'] = 'ajax_paging';
$this->pagination->initialize($config);
$resultLimited = $this->abouthistory_model->history_listLimited($start_row,$per_page);
$data["CatId"]=$this->viewbook_model->getCategory();
$data["links"]=$this->pagination->create_links();
Please help me
source
share