在我的节目中,我有会议
我发布了一些代码
CONTROLLER:
function __construct()
{
parent::__construct();
$this->is_logged_in();
}
function check_in_client() {
$this->load->model('membership_model');
$this->load->library('javascript');
$this->load->view('check_in_cliente');
if(isset($_GET['term'])) {
$result= $this->membership_model->check_in_client($_GET['term']);
if(count($result) > 0) {
foreach($result as $pr)
$arr_result[] = $pr->name;
echo json_encode($arr_result);
}
}
模特:
function check_in_client($name) {
$this->db->like('nome',$name, 'both');
return $this->db->get('clienti')->result();
}
查看:
<link rel="stylesheet"href="//code.jquery.com/ui/1.11.4/themes/smoothness/jqueryui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script type="text/javascript">
$(document).ready(function() {
$('#client_name').autocomplete({
source: "<?php echo site_url('site/check_in_client/?'); ?>"
});
});
</script>
<input type="text" name="client_name" id="client_name" placeholder="nome" />
浏览器中的结果是当我在输入栏中输入内容时
没有搜索结果。
有人帮助我吗?非常感谢 最好的问候
答案 0 :(得分:1)
将$_GET['term']
更改为$_REQUEST['term']
function check_in_client() {
$this->load->model('membership_model');
$this->load->library('javascript');
$this->load->view('check_in_cliente');
if(isset($_REQUEST['term'])) {
$result= $this->membership_model->check_in_client($_REQUEST['term']);
if(count($result) > 0) {
foreach($result as $pr)
$arr_result[] = $pr->name;
echo json_encode($arr_result);
}
}
答案 1 :(得分:0)
希望这个能帮到你!
将$_GET['term']
更改为$this->input->get('term', TRUE)
function check_in_client() {
$this->load->model('membership_model');
$this->load->library('javascript');
$this->load->view('check_in_cliente');
if(isset($this->input->get('term', TRUE)) {
$result= $this->membership_model->check_in_client($this->input->get('term', TRUE));
if(count($result) > 0) {
foreach($result as $pr)
$arr_result[] = $pr->name;
echo json_encode($arr_result);
}
}