我试图在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