我的自动填充页面正在接收数据(来自检查firebug)但未在下拉列表中显示
输入
<script type="text/javascript">
$(function () {
$('input#username').autocomplete({
source:'/GetCustomer',
select: function (event, ui) {
$("#username").val(ui.item.value);
}
});
});
</script>
<label for="username">Enter Username: </label>
<input type="text" name="username" id="username" />
data page---GetCustomer
getCustomer页面
@{
var db1 = Database.Open("s2k");
var term = Request.QueryString["username"] + "%";
//term = "sp%";
var sql = "SELECT O_Dealer_Code from Dealer_Codes where O_Dealer_Code LIKE @0";
var result = db1.Query(sql, term);
var data = result.Select(p => new{label = p.O_Dealer_Code});
Json.Write(data, Response.Output);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
</body>
</html>
任何人都可以指出我的错误或推荐另一种从数据库自动完成的方法吗?