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

带有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 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥85 maple软件,solve求反函数,出现rootof怎么办?
    • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题