我有以下代码:
$('.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
答案 0 :(得分:1)
http://codeigniter.com/user_guide/libraries/input.html
$this->input->post('value');
答案 1 :(得分:0)
尝试使用$_REQUEST['value'];
获取值。希望这可行