我在CodeIgniter 3.0中使用Ajax_pagination
库。分页工作正常。现在我想通过页面本身传递更多参数。
例如,我有一个用户选择国家和类别的页面。现在我想用分页显示数据。这是我的代码。
function ajaxPaginationData()
{
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$totalRec = count($this->post->getRows());
//pagination configuration
$config['first_link'] = 'First';
$config['div'] = 'postList'; //parent div tag id
$config['base_url'] = base_url().'index.php/posts/ajaxPaginationData';
$config['total_rows'] = $totalRec;
$config['per_page'] = $this->perPage;
$this->ajax_pagination->initialize($config);
$data['posts'] = $this->post->getRows(array('start'=>$offset,'limit'=>$this->perPage));
$this->load->view('posts/ajax-pagination-data', $data, false);
}
这是我的分页html
<div class="pagination">Showing 1 to 5 of 8 | <b>1</b> <a onclick="$.post('http://localhost:8080/ajax/index.php/posts/ajaxPaginationData/5', {'page' : 5}, function(data){
$('#postList').html(data); }); return false;" href="javascript:void(0);">2</a> <a onclick="$.post('http://localhost:8080/ajax/index.php/posts/ajaxPaginationData/5', {'page' : 5}, function(data){
$('#postList').html(data); }); return false;" href="javascript:void(0);">></a> </div>
现在开启更改国家/地区下拉列表我想获得带有该ID的列表
<select id="country">
<option value="0">select</option>
<option value="1">USA</option>
<option value="2">UK</option>
</select>
答案 0 :(得分:1)
在功能
中传递下拉列表的值function ajaxPaginationData($country)
{
$page = $this->input->post('page');
if(!$page){
$offset = 0;
}else{
$offset = $page;
}
$totalRec = count($this->post->getRows());
//pagination configuration
$config['first_link'] = 'First';
$config['div'] = 'postList'; //parent div tag id
$config['base_url'] = base_url().'index.php/posts/ajaxPaginationData';
$config['total_rows'] = $totalRec;
$config['per_page'] = $this->perPage;
$this->ajax_pagination->initialize($config);
$data['posts'] = $this->post->getRows(array('start'=>$offset,'limit'=>$this->perPage));
$this->load->view('posts/ajax-pagination-data', $data, false);
}
并使用$ country从表中选择条件的数据。
有关分页的更多信息请尝试此http://w3code.in/2015/10/how-to-do-pagination-in-codeigniter/