我正在尝试使用 jqueryUi 进行自动完成,但无法将数据绑定(bind)到它。
$("#CustomerName").autocomplete({
source:
function () {
$.ajax({
url: "SearchCustomer?key=" + $("#CustomerName").val(),
async: false,
dataType:"json",
success: function (data) {
return data.ResultList;
}
})
},
minLength: 0, autoFocus: true, delay: 1000
});
我的ajax结果是-
{"Message":null,"Successfull":false,"Id":0,"Result":null,"ResultList":["Customer 2","Kohl\u0027s Corp","Test Corp"]}
如果我使用这个,那么它工作正常
$("#CustomerName").autocomplete({
source:["Customer 2","Kohl\u0027s Corp","Test Corp"],
minLength: 0, autoFocus: true, delay: 1000
});
提前致谢!
最佳答案
$.ajax 没有问题,您能否用 response(data.ResultList); 之类的响应包装返回的数据
$("#CustomerName").autocomplete({
source: function( request, response ) {
$.ajax({
url: "SearchCustomer?key=" + $("#CustomerName").val(),
dataType : "json",
success: function (data) {
response(data.ResultList);
}
});
},
minLength: 0,
autoFocus: true,
delay: 1000
});
关于jquery-ui - 无法使用 jQueryUI 绑定(bind)自动完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15876624/