Aagax pagination does not change the active link

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="")
{
    /*Pagination*/
    $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; // default FALSE
    $config['paging_function'] = 'ajax_paging'; // Your jQuery 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

+4
source share
1 answer

ideal ajax pagination for codeigniter, please refer to the following link:

http://tohin.wordpress.com/2008/08/12/codeigniter-ajax-pagination/

I use this while working fine ....

here is the code i used to display employee details:

- ajax controller -

public function employeeListAjax()
{
    if (!$this->input->is_ajax_request())
    {
        redirect(site_url(), 'refresh');
    }
    $config['anchor_class'] = '';
    $config['show_count'] = true;
    $config['div'] = '#emp_list'; // div for displaying ajax
    $config['base_url'] = site_url('employee/employeeListAjax');
    $config['total_rows'] = sizeof($this->emp->empdetail());
    $config['per_page'] = 10;
    $this->jquery_pagination->initialize($config);
    $data['links'] = $this->jquery_pagination->create_links();
    $data['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
    $data['empdet'] = $this->emp->empdetail($config['per_page'], $data['page']);
    $this->load->view('modules/employee/ajax_emp_list', $data);
}

- ajax script -

<script>
    jQuery(function($){
        $.post("<?php echo site_url('employee/employeeListAjax');?>",
        {
        },
        function(response)
        {
        setTimeout("showAjax('#emp_list', '"+escape(response)+"')", 100);
        });
    });
</script>

u jquery_pagination :

https://github.com/neotohin/CodeIgniter-Ajax-pagination-Library/blob/master/Jquery_pagination.php

codeigniter.

u , :

$this->load->library('Jquery_Pagination');

...

showAjax - js, :

<script>
    function showAjax(id, response)
    {
    jQuery(id).hide();
    jQuery(id).html(unescape(response));
    jQuery(id).fadeIn(200);
    }
</script>
0

All Articles