0

我有以下代码:

$('.pPage').click(function(){         
    var recordsPerPage = $(this).attr('id');
    $.ajax({
        type: "POST",
        dataType: 'json',
        url: "backOfficeUsers/displayAllUsers",
        data: { value: recordsPerPage }
    }).done(function( msg ) {
        alert( "Data Saved: " + msg );
    });
});

我需要在我的控制器中操作 recordsPerPage 变量。如何在我的控制器中接受这个变量的值并在我的 php 中使用它?

这是控制器的代码:

public function displayAllUsers()
{
    $currentUser = $this->isLoggedIn();
    $this->load->model('backOfficeUsersModel');
    $this->db->order_by('userid');

    $myrec = $this->input->post('value');
    $recordsPerPage = $myrec; 

    $limit = $recordsPerPage;
    $offset = 3;

    $offset = $this->uri->segment(3);
    $this->db->limit($limit, $offset);

    $data['users'] = $this->backOfficeUsersModel->get();

    $totalresults = $this->db->get('back_office_users')->num_rows();

    //initializing & configuring paging
    $this->load->library('pagination');
    $config['base_url'] = site_url('/backOfficeUsers/displayAllUsers');
    $config['total_rows'] = $totalresults;
    $config['per_page'] = $limit;
    $config['uri_segment'] = 3;
    $config['full_tag_open'] = '<div class="dataTables_paginate paging_bootstrap pagination"><ul>';
    $config['full_tag_close'] = '</ul></div>';
    $config['cur_tag_open'] = '<li><a href=# style="color:#ffffff; background-color:#258BB5;">';
    $config['cur_tag_close'] = '</a></li>';
    $config['num_tag_open'] = '<li>';
    $config['num_tag_close'] = '</li>';

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

    $data['main_content'] = 'bousers/users';
    $data['title'] = 'Back Office Users';
    $errorMessage = FALSE;

    $this->load->vars($data,$errorMessage);
    $this->load->vars($currentUser);
    $this->load->view('backOffice/template');

} // end of function displayAllUsers
4

2 回答 2

1

http://codeigniter.com/user_guide/libraries/input.html

$this->input->post('value');
于 2012-10-03T01:36:44.520 回答
0

尝试使用 $_REQUEST['value'];希望这会起作用

于 2012-10-03T09:08:06.750 回答