issue with autocomplete + asp.NET MVC
Hi. I am new to jQuery, right now I am trying to create a functionality in which a user could start typing a name in a textbox and it will suggest names from the clients database (like google suggestions). I have imported the following scripts:
<script type="text/javascript" src="../../Scripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.ui.core.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.ui.position.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.ui.autocomplete.js"></script>
And my code looks like this:
$("#ConsigneeName").autocomplete({
source: "Home/Find",
minLength: 2,
mustMatch: true
});
The problem I am having right now is that the parameter is not making it to the Controller Action, if I type "ALC" the parameter gets to the Contoler Action like an empty string. My Action method returns JsonResult. If I omit the parameter in the method, then it works. see code below:
public JsonResult Find(string q)
{
IList<string> list = new List<string>();
string x = "Alcides";
list.Add(x);
string y = "Alejandro";
list.Add(y);
string w = "Alicia";
list.Add(w);
string z = "Alejandra";
list.Add(z);
return Json(list);
}
Can you help me determine where I am doing it wrong?
regards,
Alcides