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

时间:2020-12-08 14:31:00

I want to implement Pjax jquery library with codeigniter Other function just works fine. But when i added it woth pagination and its dont works. when i Click pagination button than its change url but suddenly after its reloading with normal php not ajax..

我想用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 个解决方案

#1


1  

I solved the problem with:

我解决了这个问题:

$.pjax.defaults.timeout = 3000;

#2


0  

Just try the below config value

只需尝试以下配置值

$config['page_query_string'] = TRUE

#3


0  

How can you get $config["total_rows"]??

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

I think it should $config["total_rows"] = $this->member->browse_search_total($FilterData)->num_rows();

我认为它应该是$ config [“total_rows”] = $ this-> member-> browse_search_total($ FilterData) - > num_rows();

#1


1  

I solved the problem with:

我解决了这个问题:

$.pjax.defaults.timeout = 3000;

#2


0  

Just try the below config value

只需尝试以下配置值

$config['page_query_string'] = TRUE

#3


0  

How can you get $config["total_rows"]??

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

I think it should $config["total_rows"] = $this->member->browse_search_total($FilterData)->num_rows();

我认为它应该是$ config [“total_rows”] = $ this-> member-> browse_search_total($ FilterData) - > num_rows();