dongyirong3564 2016-09-10 18:33
浏览 47

JQuery Autocomplete无法在Codeigniter中运行

This is the jquery at the head:

$(function(){
    var $sfield = $('#term').autocomplete({
        source: function(request, response){
            var url = "<?php echo site_url('admin/get_email'); ?>";
              $.get(url, {term:request.term}, function(term){
                response($.map(term, function(countries) {
                    return {
                        value: aauth_users.email
                    };
                }));
              }, "json");  
        },
        minLength: 2,
        autofocus: true
    });
});

This is my view:

<form action="admin/get_email" method="get" accept-charset="utf-8">
    <div class="form-group">
        <label for="remail">Recipient Email Address</label>
            <input type="email" class="form-control" id="term" name="term" placeholder="Email">
    </div>
</form

This is my Controller:

public function get_email()
    {
        $this->load->model('suggest_email');
        $term = $_GET['term'];
        $countries = $this->suggest_email->get_email($term);
        echo json_encode($countries);
    }

and this is my model:

class Suggest_email extends CI_Model
{
  function get_email($term)
  {
    $this->db->like('email', $term, 'after');
    $query = $this->db->get('aauth_users');
    return $query->result();
  }
}

In chrome console, I can clearly see an error:

http://[::1]/sent/theme/js/jquery.min.js:4 [GET] http://[::1]/sent/index.php/admin/get_email?term=vivo@att.com 500 (Internal Server Error)

  • 写回答

1条回答 默认 最新

  • dongyuchen9276 2016-09-13 11:59
    关注

    The program can't locate your js files for jquery and jquery ui. Please add them at the bottom of the page after the closing body tag. You'll need access to internet for the following cdn links to work.

    <script   src="https://code.jquery.com/jquery-3.1.0.slim.min.js"   integrity="sha256-cRpWjoSOw5KcyIOaZNo4i6fZ9tKPhYYb6i5T9RSVJG8="   crossorigin="anonymous"></script>
    <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js" integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E=" crossorigin="anonymous"></script>
    
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因