在CodeIgniter 3.0中传递Ajax_pagination中的更多参数

时间:2015-10-08 08:08:07

标签: ajax codeigniter pagination

我在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 | &nbsp;<b>1</b>&nbsp;<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>&nbsp;<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);">&gt;</a>&nbsp;</div>

现在开启更改国家/地区下拉列表我想获得带有该ID的列表

<select id="country">
<option value="0">select</option>
<option value="1">USA</option>
<option value="2">UK</option>
</select>

1 个答案:

答案 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/