Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Typehead js live search在codeigniter中不工作_Jquery_Ajax - Fatal编程技术网

Jquery Typehead js live search在codeigniter中不工作

Jquery Typehead js live search在codeigniter中不工作,jquery,ajax,Jquery,Ajax,我有一个产品网站和一个搜索框来搜索codeigniter中的产品 我的视图文件: <input type="text" class="form-control" name="typeahead" placeholder="Search Product." style="height:32px; margin: 25px 0px;" > 当我使用硬代码时,链接是http:/localhost/products/user/search/dairymilk,它可以工作。。但是当我在

我有一个产品网站和一个搜索框来搜索codeigniter中的产品

我的视图文件:

 <input type="text" class="form-control" name="typeahead" placeholder="Search Product."  style="height:32px; margin: 25px 0px;"  >
当我使用硬代码时,链接是http:/localhost/products/user/search/dairymilk,它可以工作。。但是当我在文本框中键入时,它不起作用???

首先将$'input.typeahead'更改为$'input[name=typeahead]'没有任何类像typeahead这样

remote:"<?php echo base_url('user/search').'/'?>"+$(this).val().
即使出现任何错误,也要在控制台中检查typeahead是否正在加载。您不能向警报“%QUERY”发出警报;它将给出错误

function search()
{
    $key=$this->uri->segment(3);
    $array = array();

    $query = $this->general->search($key);
    foreach($query->result() as $row)
    {
      $array[] = $row->pr_name;
    }
    echo json_encode($array);
}
remote:"<?php echo base_url('user/search').'/'?>"+$(this).val().