duanche8554 2018-08-30 12:25
浏览 1239

带有ajax函数调用的autocomlete列表在jquery.min.js错误中显示错误“s.send(t.hasContent && t.data || null)”

I try to make an autocomplete list and I'm getting data from a database using Ajax, I'm using CodeIgniter framework, but the problem is that I get an error in the console and it's related to the jequry.min.js, this my code in 3 step mvc: the controller :

 function get_autoComplete(){
    $keyword=$this->input->post('keyword');
    $data=$this->waiting_model->GetRow($keyword);
    echo json_encode($data);


}

model :

   public function GetRow($keyword) {
    $this->db->order_by('id', 'DESC');
    $this->db->like("firsName", $keyword);
    return $this->db->get('patients')->result_array();

}

and the view

<div class="os-tabs-controls os-tabs-complex">
        <div class="form-group">
            <input  type="text" id="patients_search" autocomplete="off" name="patients_search" class="form-control" placeholder="patient name">
            <ul class="dropdown-menu txttxtPatientName" style="margin-left:15px;margin-right:0px;" role="menu" aria-labelledby="dropdownMenu"  id="DropdownName"></ul>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function(){

            $("#patients_search").keyup(function () {
                $.ajax({
                    type: "POST",
                    url:  " <?php echo site_url('admin/waiting/get_autoComplete/?');?>",
                    data: {
                        keyword: $("#patients_search").val()
                    },
                    dataType: "json",
                    success: function (data) {
                        if (data.length > 0) {
                            console.log('data.length = ' + data.length);
                            $('#DropdownName').empty();
                            $('#patients_search').attr("data-toggle", "dropdown");
                            $('#DropdownName').dropdown('toggle');
                        }
                        else if (data.length == 0) {

                            $('#patients_search').attr("data-toggle", "");
                        }
                        $.each(data, function (key,value) {
                            if (data.length > 0)
                                $('#DropdownName').append('<li role="displayCountries" ><a role="menuitem dropdownCountryli" class="dropdownlivalue">' + value['name'] + '</a></li>');
                        });
                    }
                });
            });
            $('ul.txtPatientName').on('click', 'li a', function () {
                $('#test').val($(this).text());
            });

        });
    </script>

intel that I show nothing in the console as an error for this function so I rewrite the ajax function in the console I show this msg console msg

I click jquery.min.js:2426 this is the jqury librairy

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Pwm双极模式H桥驱动控制电机
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题