尝试使用ajax与select2时出现错误
getting error when trying to use ajax with select2
知道如何调试select2的ajax功能吗?下面是我试图实现的一个例子:https://jsbin.com/sohupoviko/edit?html,output和下面是http://localhost:4000/users:
的结果集[
{
"id": 1,
"first_name": "John",
"last_name": "Smith"
},
{
"id": 2,
"first_name": "John2",
"last_name": "Smith2"
}
]
这是我在本地运行代码时返回的本地错误:
jquery.min.js:2 jQuery.Deferred exception: Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined
at d (https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js:2:5214)
at Object.f.transport.d.status.0.d.status.e.trigger.message (https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js:2:4227)
at j (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:29948)
at k (http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js:2:30262) undefined
任何想法的根本原因可能是什么或如何调试?
在后端代码中,请将查询更改为使用"AS TEXT"
的例子:
$query = $mysqli->query("SELECT id, first_name, last_name AS text FROM users WHERE fist_name LIKE '%$term%'"));
while ($row = mysql_fetch_assoc($query)) {
$return[] = $row;
}
echo json_encode($return);
Credit go to -> Select2.js错误:Cannot read property 'length'未定义的
相关文章:
- Node.js v6.2.0类扩展不是函数错误
- Jquery菜单操作不稳定,定位不正确,存在一般错误
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 试图在引导模式内动态生成图表,得到offsetWidth错误
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 我如何修复包含在captcha的addthis中的错误
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 节点是否需要模块传递带有方括号的arg?这是个错误吗
- Webpack/Rect:遵循egghead.io教程,但出现错误:您可能需要一个合适的加载程序来处理此文件类型
- CKFinder 3为所选文件返回错误的URL
- 同位素库错误:未捕获错误无布局模式包装生产线8
- 铬:“;未捕获的语法错误:意外的标记:"
- 如何通过自己获得Chrome扩展的用户反馈/错误报告
- Uglify JS错误:意外字符''连接时,请缩小select2
- 使用 select2 时引导弹出框的位置错误
- 尝试使用ajax与select2时出现错误
- 在select2中获得错误,使下拉框使用文本错误Uncaught TypeError: d[b]不是函数
- Webpack的select2类型错误
- “未为 Select2 未定义错误定义查询函数”
- 未捕获的类型错误:对象 [对象对象] 没有方法“select2”