jQuery UI Autocomplete with ASP MVC

Ich versuche, jQuery Automcomplete zum Laufen zu bringen, aber es funktioniert nicht so, wie ich es möchte: P Das ist mein Code:

JavaScript:

        $("#CustomerID").autocomplete({
            source: function(request, response) {
                $.ajax({
                    type: "POST",
                    url: "/customer/search",
                    dataType: "json",
                    data: {
                        term: request.term
                    },
                    error: function(xhr, textStatus, errorThrown) {
                        alert('Error: ' + xhr.responseText);
                    },
                    success: function(data) {
                        response($.map(data, function(c) {
                            return {
                                label: c.Company,
                                value: c.ID
                            }
                        }));
                    }
                });
            },
            minLength: 2,
            select: function(event, ui) {
                alert('Select');
            }
        });

ASP MVC:

    [AcceptVerbs(HttpVerbs.Post)]
    public JsonResult Search(string term)
    {
        if (term == null)
            term = "";

        List<JSON_Customer> customers = repCustomer.FindCustomers(term).ToList();
        return Json(customers);
    }

    public class JSON_Customer
    {
        public int ID { get; set; }
        public string Company { get; set; }
    }

    public IQueryable<JSON_Customer> FindCustomers(string searchText)
    {
        return from c in _db.Customers
               where c.Company.Contains(searchText)
               orderby c.Company
               select new JSON_Customer
               {
                   ID = c.ID,
                   Company = c.Company
               };
    }

Ich erhalte die Anfrage von$.ajax und ich gebe die korrekte Kundenliste gemäß dem Suchbegriff zurück. Und diesuccess -Methode wird aufgerufen. Ich kann sehen, dassdata hat ein[object Object]wert aber was mache ich als nächstes? Es fallen keine Kunden in meine Liste. Ich benutze dasresponse($.map... code aus demhttp: //jqueryui.com/demos/autocomplete/#remote-json aber es wird einfach nicht funktionieren.

Weiß jemand warum?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage