Click here to Skip to main content
13,043,865 members (47,871 online)
Rate this:
Please Sign up or sign in to vote.
See more:
In my view i have

@Html.TextBoxFor(per => per.Hospital, new { style = "width:220px", @maxlength = "50", data_autocomplete = Url.Action("HospitalList", "Person") })

My jquery is

$(document).ready(function () {        
    $('input[data_autocomplete]').each(function () {
        var url = $(this).data('autocomplete');
            source: function (request, response) {
                $.getJSON(url, {
                    term: request.term
                }, response);

And a created a new Action result

public ActionResult HospitalList(string term)
        List<string> result = new List<string>();
        result.Add("Hospital 1");
        result.Add("North Central Bronx Hospital");            
        return Json(result , JsonRequestBehavior.AllowGet);

now where am i going wromg. All I see a a text box , no behavior of auto complete. Should i be including any jquery library for it to work
Posted 5-Apr-13 9:39am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is because you have wrong autocomplete source, which is supposed to be an array, or a string or a function. In your case, the response function lacks return statement which is a main part defining the autocomplete data.

Please see:[^].

Pay attention for the sample "Using a custom source callback to match only the beginning of terms".

See also:[^].


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 5 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100