我試圖在Codeigniter中使用分頁列表。我願意使用jQuery ajax在列表中進行排序。它適用於第一頁分頁。我可以在該頁面中進行升序和降序排序。但是當我點擊其他頁面時。這是行不通的。排序不能在分頁的第2頁上工作
可能是什麼問題。任何人都可以建議我嗎?
在此先感謝。
這是我的控制器
function listData(){
$this->clear_sample_id_catche();
$out=$this->Mgeneral->listData();
$per_page = 10;
$total = $this->Mgeneral->countData();
$data = $this->Mgeneral->listData($per_page, $this->uri->segment(3));
$base_url = site_url('general/listData');
$config['base_url'] = $base_url;
$config['total_rows'] = $total;
$config['per_page'] = $per_page;
$config['uri_segment'] = '3';
$this->pagination->initialize($config);
$data=array('body'=>'list','out'=>$data);
$this->load->view('template',$data);
}
代碼這是我的模型
function listData($limit = NULL, $offset = NULL)
{
$this->db->limit($limit, $offset);
$data=array();
$q=$this->db->get('tbl_sample_id');
if($q->num_rows()>0)
{ $data=$q->result_array();
return $data;
}
}
,我必須使用AJAX爲
<script type="text/javascript">
$(文件)。就緒(函數(){ $(「#internal」)。click(function(){
$.ajax({url:"general/listData_internal_ascending",success:function(result){
$("body").html(result);
}});
});
});
謝謝
哪裏是你的代碼? – 2012-04-17 06:45:29
頁面值和搜索值不一起發送,或者您忘記使用LIMIT和OFFSET。 – 2012-04-17 06:46:42
如果您向我們顯示您的代碼,那麼我們將能夠幫助您。 – CJS 2012-04-17 06:52:07