如何使用pjax实现Codeigniter默认分页

时间:2015-05-04 06:03:46

标签: codeigniter pagination pjax

我想用codeigniter实现Pjax jquery库其他函数运行正常。但是,当我添加它时,它会分页并且它不起作用。当我点击分页按钮比它的更改网址但突然重新加载后,正常的PHP不是ajax ..

$this->load->library('pagination');

    $FilterData = $this->input->get();

    $config = bootstrapPagination();
    $config['base_url'] = main_url('members');

    $config["total_rows"] = $this->member->browse_search_total($FilterData);
    $config["per_page"] = PER_PAGE;
    $config['reuse_query_string'] = TRUE;
    $this->pagination->initialize($config);

    $data["links"] = $this->pagination->create_links();

    $data['members'] = $this->member->browse_search($FilterData, PER_PAGE, $offset);


    $this->pagination->initialize($config);

    $data['links'] = $this->pagination->create_links();
 if (isset($_SERVER['HTTP_X_PJAX']) && $_SERVER['HTTP_X_PJAX'] == TRUE)
    {
        $this->load->view('show_members', $data);
    } else
    {
        $this->output->set_template('frontend');
        $this->output->set_title('Members | ' . sitename());
        $this->load->view('show_members', $data);
    } 

3 个答案:

答案 0 :(得分:1)

我用以下方法解决了问题:

$.pjax.defaults.timeout = 3000;

答案 1 :(得分:0)

试试下面的配置值

$config['page_query_string'] = TRUE

答案 2 :(得分:0)

你怎么能得到$config["total_rows"] ??

我认为应$config["total_rows"] = $this->member->browse_search_total($FilterData)->num_rows();