我正在尝试在 jQuery 自动完成中获取所有用户名,但它似乎根本不起作用。
控制器-
public ActionResult Allusers(string Email) {
if (ModelState.IsValid) {
var allUser = (from us in db.SystemUsers
select new UserModel
{
Email=us.Email,
UserId=us.UserId
}).Distinct().ToArray();
// ViewBag.Team = allUser.OrderBy(x => x.Text);
return Json(allUser,JsonRequestBehavior.AllowGet);
}
return View();
}
脚本-
<script type="text/javascript">
$(function () {
$("input #autocomplete").autocomplete({
source: function (request, response) {
$.ajax({
url: '/AllUsers/AllUsers/',
type: "POST",
dataType: "json"
});
}
});
});
</script>
遵循我正在使用的脚本-
<script src="../../Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.11.js" type="text/javascript"></script>
但没有运气。