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
Try adding the city data as extraParms:
This is assuming the $(‘#City’) is an input of type text when using the .val
— Edited —
Based on your feedback the answer is:
The controller should be:
The jquery would be: