这是我的模型,该模型从数据库中获取数据并在表中显示所有数据
public function get_masteradmin_data($limit,$skip)
{
$mongo = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
//$filter = ['full_name' => 'www'];
$filter = [];
$options =[
'projection' => [
'_id' => 0,
'full_name' => 1,
'username' => 1,
'designation'=> 1,
'department'=> 1,
'official_mobile_no'=> 1,
'official_email_id'=> 1,
'select_user_type'=> 1,
'permission'=> 1,
],
'sort' => [
'_id' => -1
],
'skip' => $skip,
'limit' => $limit,
];
$query = new MongoDB\Driver\Query($filter, $options);
$result = $mongo->executeQuery('justrack_db.master_admin', $query);
$res = array();
foreach($result as $r)
{
$res[] = $r;
}
return json_encode($res,true);
//return $res;
}
这是我的控制器,我可以在其中获取数据
public function get_masteradmin_data()
{
$this->load->model('AppconfigModel');
$config =[
'base_url' => base_url('Appconfig/master_admin'),
'per_page' =>7,
'total_rows' =>$this->AppconfigModel->get_no_of_doc(),
'use_page_numbers' => TRUE,
];
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$result= $this->AppconfigModel->get_masteradmin_data($config['per_page'],$page);
echo ($result);
}
我想通过使用此模型来添加实时数据搜索功能。我已经从数据库中获取数据了。
这是我对keyup函数进行实时数据搜索的Ajax查询。我无法继续使用AJAX功能。请为此提供帮助
function ajaxSearch() {
var input_data = $('#search_data').val();
if (input_data.length === 0) {
$('#suggestions').hide();
} else {
var post_data = {
'search_data': input_data,
'<?php echo $this->security->get_csrf_token_name(); ?>': '<?php echo $this->security->get_csrf_hash(); ?>'
};
$.ajax({
type: "POST",
url: