http://jqueryui.com/autocomplete/#remote自動完成只運行一次,當頁面加載或一個信打,但只有一次
$(document).ready(function() {
var Employees = function(request, response) {
var value1 = document.getElementById('<%= txtEmployeeID.ClientID %>').value.split(" ");
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/GetEmployees",
data: "{'keywords':'" + value1 + "'}",
dataType: "json",
async: true,
success: function(data) {
response(data.d);
},
error: function(result) {
//alert("Error");
}
});
}
$('#<%= txtEmployeeID.ClientID %>').autocomplete({
autoFocus: true, source: Employees
});
});
這是自動完成從數據庫中獲取價值的代碼。
當每個字母被輸入然後過濾值時,它會運行。
我正在尋找自動完成功能,將在啓動時加載所有員工姓名到var Employee中,然後無需重試過濾自動完成將通過自動過濾作爲功能來完成。