php - ajax call in pagination on codeigniter -


i have pagination in controller :

<?php $nama = $this->session->userdata('nama'); $start_row = $this->uri->segment(3); $per_page = 5;  if (trim($start_row) == '') { $start_row = 0; };  $total_rows = $this->model_request->countperuser($this->session->userdata('nama'));  $this->load->library('pagination'); $config['base_url'] = base_url() . 'control_closing/show'; $config['total_rows'] = $total_rows; $config['per_page'] = $per_page; $config['full_tag_open'] = '<div class="pagination pagination-centered"><ul>'; $config['full_tag_close'] = '</ul></div><!--pagination-->'; $config['first_link'] = false; $config['last_link'] = false; $config['first_tag_open'] = '<li>'; $config['first_tag_close'] = '</li>'; $config['prev_link'] = 'prev'; $config['prev_tag_open'] = '<li class="prev">'; $config['prev_tag_close'] = '</li>'; $config['next_link'] = 'next'; $config['next_tag_open'] = '<li>'; $config['next_tag_close'] = '</li>'; $config['last_tag_open'] = '<li>'; $config['last_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a href="#">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li>'; $config['num_tag_close'] = '</li>';  $this->pagination->initialize($config);  $data['pagination'] = $this->pagination->create_links(); $request = $this->model_request->selectrequestperuser($nama, $per_page, $start_row);  $data['data_request'] = $request; $this->load->view('view_closing', $data); ?> 

this modal :

public function selectrequestperuser($nama_user, $limit, $start_row ) {    $query = $this->db->get_where('tbl_requestfix', array('nama_user' => $nama_user), $limit, $start_row);    return $query->result_array(); }  public function countperuser($nama_user) {   $query = $this->db->get_where('tbl_requestfix', array('nama_user' => $nama_user));   return $query->num_rows(); } 

i decided divide view 2 file better looking , easy maintenance.

this main view named view_closing:

<div class="container-fluid-full"> <div class="row-fluid">      <?php $this->load->view('/include/sidebar_closing.php'); ?>      <div id="content" class="span10">         <ul class="breadcrumb">             <li>                 <i class="icon-home"></i>                 <a href="<?php echo base_url() . 'control_member'; ?>">home</a>                  <i class="icon-angle-right"></i>             </li>             <li><a href="#">closing</a></li>         </ul>          <div class="row-fluid sortable" id="isi">                <div class="box span12">                 <div class="box-header">                     <h2><i class="halflings-icon align-justify"></i><span class="break"></span>data request</h2>                     <div class="box-icon">                         <a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>                     </div>                 </div>                 <div class="box-content">                     **<?php $this->load->view('view_closing_table'); ?>**                 </div>             </div>         </div>     </div> </div> 

for table linked pagination named view_closing_table

<table class="table table-bordered table-striped table-condensed" id="table1"> <thead>     <tr>         <th>no.  </th>         <th>no request</th>         <th>kirim request</th>         <th>keluhan</th>                                                     <th>status</th>         <th>approved by</th>         <th>it handle</th>         <th>estimasi penyelesaian</th>         <th>action</th>     </tr> </thead>    <tbody>     <?php     $no = 1;     foreach ($data_request $data) {         ?>         <tr>             <td class="center"><?php echo $no++ . ". "; ?> </td>              <td class="sorting1" id='no_request' data-id-reseh="<?php echo $data['id_request']; ?>"><?php echo $data['kode_kantor'] . '/' . $data['kode_departement'] . '/' . date('m', strtotime($data['bulan'])) . '/' . $data['id_request']; ?></td>              <td class="center"><?php echo date("d-m-y, h:i ", strtotime($data['waktu_mulai'])); ?></td>              <td class="center" id="description"><?php echo $data['keluhan']; ?></td>                                                          <td class="center"><a href="#" id="status" name="status" class="linkstatus" ><span class="label label-success" ><?php echo $data['status_request']; ?> </span></a></td>               <td class="center"><?php echo $data['by_who'] ?></td>             <td class="center"><?php echo $data['it_person'] ?></td>             <td class="center"><?php                 if ($data['tanggal_estimasi'] != null) {                     echo date("d-m-y ", strtotime($data['tanggal_estimasi'])) . ', ' . date("h:i ", strtotime($data['jam_estimasi']));                 } else {                     echo "";                 }                 ?></td>                                                         <!-- action-action -->             <td  class="center" width="10px">                 <a class="btn btn-success" >                     <i class="halflings-icon white print" id="print"></i>                     print                 </a>                      </td>         </tr>      <?php } ?> </tbody> 

my problem how make pagination when call next or previous refreshing table not page. think jquery ajax can it. code unfortunatelly not working.

$('.pagination ul li a').click(function(){ var this_url = $(this).attr("href");  $.post(this_url,{ }, function(data){     ('div#table1').html(data);     });     return false; }); 

any appriciated.

('div#table1').html(data); should $('#table1').html(data);

now depends on comes in data.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -