person! I really need help, I'm trying to do an Autocomplete with multiple inputs in ASP.NET Core, but at the moment I'm only able to return one value. When I enter the person's name I can bind the city, I would like to bind email, department
[HttpPost]
public JsonResult AutoCompletePeoples(string prefix)
{
var pessoas = (from pessoa in _context.Pessoas
where pessoa.NamePeople.StartsWith(prefix)
select new
{
label = pessoa.NamePeople,
val = pessoa.City
}).ToList();
return Json(pessoas);
}
<script type="text/javascript">
$(function () {
$("#txtNomeVisitante").autocomplete({
source: function (request, response) {
$.ajax({
url: '/Visitas/AutoCompletePeoples/',
data: { "prefix": request.term },
type: "POST",
success: function (data) {
response($.map(data, function (item) {
return item;
}))
},
error: function (response) {
alert(response.responseText);
},
failure: function (response) {
alert(response.responseText);
}
});
},
select: function (e, i) {
$("#txtCity").val(i.item.val);
},
minLength: 1
});
});
</script>
