dongzheng7165 2015-03-12 06:31
浏览 37

codeigniter-autocomplete无法正常工作并且没有显示错误

i like to have auto complete search function in my website. There is a page on website that has search filters. When a user lands on this page all the record of users are shown in table format on that page. There is an input box that filters out the result. for example, if i type player, the table may look like below.

ID Player

1 player win

2 player win

3 player win

Please tell me how to do that?this is what my code looks like at the moment...

View:

  <html>
    <title></title>
    <head>
    <!-- Jquery Packages -->
    <link type="text/css" rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css "/>
    <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <!-- Jquery Package End -->
    <script type="text/javascript">

            $('#txtinput').autocomplete({
                source: source: "<?php echo site_url('record/index/?'); ?>"
});
    </script>

    </head>

    <body>
    <!-- Your Input Text Box-->
    <input type="text" id="txtinput" size="20" />

    </body>
    </html>

controller :

 public function index(){

         $this->load->helper('url');
         $this->load->helper('html');
         $this->load->library('javascript');
         $this->load->library('javascript/Jquery');
         $this->load->view('record_view');
        $this->load->model('record_model'); 

         if (isset($_GET['term'])){

             $result = $this->record_model->getData($_GET['term']);

         if (count($result) > 0){

            foreach ($result as $key ) {
                $abc[] = $key->result;

}
                echo json_encode($abc);
         }


}
}

Model:

 public function getData($result)
    { 
        $this->db->like('result', $result, 'both' );
        return $this->db->get('history')->result();
    }
  • 写回答

1条回答 默认 最新

  • douhui4831 2015-03-12 08:56
    关注
    $('#txtinput').autocomplete({
                    source: **"source:"** "<?php echo site_url('record/index/?'); ?>"
    });
    

    remove extra source..

    and put $this->load->view('record_view'); in else of get controller

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度