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 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题