Jquery AutoComplete Plugin calling
- by martinezgeovani
When I use JQuery's autocomplete and hardcode the array values in the page it works wonderful; but what I need to do is obtain the array values from either a web service or from a public function inside a controller. I have tried various way and can't seem to make it work. The farthest I got is pulling the data in to a long string and when the auto complete results are provided it's the long string which matches, which I understand why.
$("#TaskEmailNotificationList").autocomplete("http://localhost/BetterTaskList/Accounts/registeredUsersEmailList", {
multiple: true,
mustMatch: false,
multipleSeparator: ";",
autoFill: true
});
has anyone encountered this? I am using C#.
UPDATE:
The below code is a step forward I am now getting an array returned but I think I'm processing it wrong on my page.
var emailList = "http://localhost/BetterTaskList/Account/RegisteredUsersEmailList";
$("#TaskEmailNotificationList").autocomplete(emailList, {
multiple: true,
mustMatch: false,
multipleSeparator: ";",
autoFill: true
});
[HttpGet]
public ActionResult RegisteredUsersEmailList()
{
BetterTaskListDataContext db = new BetterTaskListDataContext();
var emailList = from u in db.Users select u.LoweredUserName;
return Json(emailList.ToList(), JsonRequestBehavior.AllowGet);
}