对我而言,这是我第一次使用Bootstrap Typeahead。 我希望在预先输入中显示20个联系人列表:
Alex Steven +393333333333
.....
....
Lee Sloane +393323349530
作为第一步,我写道:
typeahead: {
source: function(queryForHints) {
if(queryForHints.length<4)
return '';
var parameters = {'queryForHints': queryForHints};
jQuery.ajax({
url: "/thisroute",
data: parameters,
type: "POST",
dataType: "json",
success: function (data) {
return data;
},
error: function (data) {
console.log("error for xxxxx/xxxxx");
},
async: true
});
}
在路由中我有一个返回如下数组的SQL查询:
Array
(
[0] => Array
(
[value] => +393323243523
[text] => Edan Constance (+393323243523)
)
[1] => Array
(
[value] => +393323349530
[text] => Lee Sloane (+393323349530)
)
in&#34; data&#34;我有ajax调用的结果(因此成功):
[Object, Object, .............. etc]
0
:
Object
text
:
"Dean Leandra (+393334029137)"
value
:
"+393334029137"
现在在consolle中我收到此错误并且没有任何内容出现:
Uncaught TypeError: Cannot read property 'success' of undefined
我如何解决我的问题?