jQuery自动完成未显示所需结果 [英] Jquery autocomplete not showing the desired result
本文介绍了jQuery自动完成未显示所需结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有此代码
$("#tb1").autocomplete({
source: function (request, response) {
$.ajax({
url: "../mycontroller/getdata",
dataType: "json",
data: { strText: "" },
success: function (Data) {
response($.map(Data.Data, function (item) {
return {
label: item.Name,
value: item.Id
};
}));
}
});
},
minLength: 1,
select: function (event, ui) {
alert(ui.item ? "Selected: " + ui.item.label : "Nothing selected, input was " + this.value);
}
});
我在文本框中得到结果,但是它显示列表中的所有项目,而不是显示已选择的项目.
I get the result in textbox, however it shows all the items in list instead of showing seleted items.
例如:- 在文本框中输入"ab"后,它应该显示所有带有ab的项目,但它显示带有ca,as和其他字母组合的项目.
For example:- After i enter "ab" in textbox it should display all the items with ab but it shows items with ca, as and other alphabets combinations.
我在做什么错,我该如何解决?
what am i doing wrong, how can i resolve it?
推荐答案
更改此内容:
data: { strText: "" }
收件人:
data: { strText: $("#tb1").val() }
您没有发送文本框输入的值,因此它将带来所有记录.
you are not sending the textbox entered value so it is bringing all records.
这篇关于jQuery自动完成未显示所需结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文