0
我有Bootstrap Typeahead的这个问题。BS Typeahead不显示结果
HTML标记:
<div class="form-group">
<label for="">Recipients</label>
<input id="recipients" name="recipients"
autocomplete="off"
class="form-control"
data-role="tagsinput">
</div>
的JavaScript:
$('#recipients').tagsinput({
allowDuplicates: false,
trimValue: true,
confirmKeys: [13, 44],
typeahead: {
source: function(queryForHints) {
if (queryForHints.length < 4)
return '';
var parameters = {
'queryForHints': queryForHints
};
jQuery.ajax({
url: "/xxxx/xxxx",
data: parameters,
type: "POST",
dataType: "json",
success: function(data) {
return (data);
},
error: function(data) {
console.log("error for xxxxx/xxxxx");
},
async: true
});
}
}
});
阿贾克斯电话后,我得到这个数组:
[{
"value": "+393334029137",
"text": "Dean Leandra (+393334029137)"
}, {
"value": "+393333419836",
"text": "Alfonso Erasmus (+393333419836)"
}, {
"value": "+393173833341",
"text": "Travis Aquila (+393173833341)"
}, {
"value": "+393334998841",
"text": "Conan Preston (+393334998841)"
}]
的问题是:我什么也看不到:(没有出现typeahead不起作用
在控制台中,我得到这个错误
bootstrap-tagsinput.js:331 Uncaught TypeError: Cannot read property 'success' of undefined
你能帮我解决这个问题?
什么是您的AJAX调用数组中的null?错字? – James
现在我决心在你提出的问题......现在从AJAX调用返回我有: [{ “值”:“393334029137”, “文”:“院长Leandra(393334029137)” }, { “值”: “393333419836”, “文本”: “阿方索的Erasmus(393333419836)” },{ “值”: “393173833341”, “文本”:“特拉维斯雕(393173833341) “ },{ ”value“:”+393334998841“, ”text“:”Conan Preston(+393334998841)“ }] –
帮助我们为您提供帮助。你需要清楚3件事情。 1.您使用的是哪个版本的引导程序。 2.你使用的是哪个插件3.在ajax调用 – naveen