我正在使用ajax刷新jquery autocomplete
的数据源以获取搜索功能。当用户使用单个字母进行搜索时,db返回> 3千条记录。在那种情况下,小部件停止响应。请在下面找到我的代码。
$("#customer_serach").autocomplete({
source: [],
search: function(event, ui) {
searchKey = $.trim($(this).val());
//alert(searchKey);
populateClientDetails(searchKey);
}
});
$.ajax({
url: url,
dataType: 'json',
async: true,
success: function(data) {
$.each(data, function(key, value) {
if (key == 'customerDetails') {
var customerDetails = data.customerDetails;
$.each(customerDetails,
function(key, value) {
customer_list
.push(value);
});
}
});
$("#customer_serach").autocomplete("option", "source", customer_list);
}
})
当用户使用单个字母搜索键进行搜索时,这是代码问题还是需要限制从db获取的记录数。