Q:

MVC with Autocomplete Not working

I have this code that does the auto complete but apparently I am doing something wrong as it not working.
This is my view:
@Html.EditorFor(model => model.city)<br />
@Html.ValidationMessageFor(model => model.city)

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js' type="text/javascript"></script>
<script src='<%: Url.Content("~/Scripts/jQueryUI/jquery-ui-1.8.2.custom.min.js") %>'
    type="text/javascript"></script>
<script type="text/javascript">    
    $("#city").autocomplete({
        source: '<%: Url.Action("Location", "CityList") %>'
    });        
</script>

This is my controller:
public class LocationController : Controller
{
    private pEntities db = new pEntities();

    public ActionResult CityList(string city)
    {
        var results = from c in db.CityCodes
                      where c.city.StartsWith(city)
                      select new { label = c.city, id = c.city_id };
        return Json(results.ToArray(), JsonRequestBehavior.AllowGet);
    }

A:

I think your problem is this:
Url.Action("Location", "CityList")

Url.Action takes the action name first, and then the controller "name."  I find that counter-intuitive as well.  Do this instead:
Url.Action("CityList", "Location")

Update:
I've looked at the documentation for the jQuery autocomplete plugin, and it looks like your controller should be accepting a parameter named term, not city.  Perhaps that's the other half of the problem you're encountering.
public ActionResult CityList(string term)
{
    // ...
}

A:

the first problem was Url.Action is not getting resolved inside the javascript and the second problem like Jacob said was i had to use term.
i just used below url instead of url action.
$("#city").autocomplete({
        source: 'Location/CityList'
    }); 

