Javascript 使用ajax内容选择

Javascript 使用ajax内容选择,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我无法解决这个问题。问题的内容: select2.full.js:4025未捕获类型错误:无法读取未定义的属性“slice” 在DecoratedClass.HidePlaceholder.removePlaceholder中选择2.full.js:4025 在DecoratedClass.removePlaceholder中选择2.full.js:594 在DecoratedClass.HidePlaceholder.append中选择2.full.js:4008 在DecoratedClas

我无法解决这个问题。问题的内容:

select2.full.js:4025未捕获类型错误:无法读取未定义的属性“slice” 在DecoratedClass.HidePlaceholder.removePlaceholder中选择2.full.js:4025 在DecoratedClass.removePlaceholder中选择2.full.js:594 在DecoratedClass.HidePlaceholder.append中选择2.full.js:4008 在DecoratedClass.append中选择2.full.js:594 在Select2。选择2.full.js:1025 在Select2.Observable.invoke中调用Select2.full.js:651 在Select2.Observable.trigger上选择Select2.full.js:641 在Select2.trigger上选择Select2.full.js:5489 在select2.full.js:5348 在Object.options.transport.self.trigger.message中选择2.full.js:3482

我做错了什么

$document.readyfunction{ $'select2'。选择2{ 最小输入长度:1, 宽度:“300px”, 占位符:选择父菜单, 阿贾克斯:{ 类型:get, url:../test/inc/ajax/ajaxlux.php, 数据类型:“json”, 安静百万:100, 数据:functionparams{ 返回{ 查询:params.term,//搜索词 页数限制:10//页面大小 }; 控制台日志数据; }, 结果:功能数据{ var newData=[]; 对于变量i=0;i'; 这就是我如何设置我的,以使其工作:

        $('#select2').select2({
            minimumInputLength:1,
            width: '300px',
            placeholder:"Select Parent Menu",
            ajax: {
                type:"get",
                url: "../test/inc/ajax/ajaxlux.php",
                dataType: 'json',
                quietMillis: 100,
                data: function(params) {
                    return {
                        query: params.term, //search term
                        page_limit: 10 // page size 

                    };
                    console.log(data);
                },

                processResults:  function(data) {
                    newData =    $.map(data, function (ind, item ) {
                        item.id = item.FormID;
                        item.text = item.FormName;
                        return item;
                    } );

                    return { results: newData };
                },

            }
        });

如果问题发生在客户端,什么时候发生?在AJAX调用返回之前还是之后?如果是在之后,AJAX调用返回什么?当我在Selecta中键入内容时会发生这种情况。所以客户端。我不知道ajax,我只想让我绊倒这个例子。从我看到的,你没有遵循select2使用的布局