I'm using the Autocomplete of jQuery UI, the point is that I receive an array from my controller and it does not show me the data (ASP.NET)
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script src="~/Scripts/jquery-ui-1.12.1.min.js"></script>
<script>
$(function () {
$('#producto').autocomplete({
source: "/Producto/BuscarProducto"
});
});
<div class="col-md-12">
<div class="tile">
<h3 class="tile-title">Cliente</h3>
<div class="tile-body">
</div>
<h3 class="tile-title mt-4">Producto</h3>
<div class="tile-body">
<form class="row ">
<div class="form-group col-md-3">
<label class="control-label">Nombre Producto</label>
<input id="producto" class="form-control" type="search" placeholder="Ingrese el nombre del Producto">
</div>
</form>
</div>
</div>
</div>
my controller
//BUSCAR PRODUCTOS
public JsonResult BuscarProducto(string term)
{
using (ApplicationDbContext db = new ApplicationDbContext())
{
var resultado = db.productos.Where(x => x.NombreProducto.Contains(term)).Select(x =>new { x.NombreProducto, x.PrecioProducto }).Take(5).ToList();
return Json(resultado, JsonRequestBehavior.AllowGet);
}
}