jQuery autocomplete pass null paramter to the controller in ASP.NET MVC 2

Posted by myaesubi on Stack Overflow See other posts from Stack Overflow or by myaesubi
Published on 2010-03-25T15:04:16Z Indexed on 2010/03/26 0:53 UTC
Read the original article Hit count: 480

Filed under:
|
|

I'm using jQuery autocomplete plugin from jQuery website calling the controller url which return json in return. The problem is the parameter sent to the controller is always null.

Here is the in-browser jQuery code for the autocomplete:

$(document).ready(function() {
    var url = "/Building/GetMatchedCities";
    $("#City").autocomplete(url);
});

and here is the ASPNET MVC controller signature in C#:

public JsonResult GetMatchedCities(string city)
{
    ..
    return this.Json(query, JsonRequestBehavior.AllowGet);
}

Thanks in advance,

Mohammad

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about autocomplete