Jquery AutoComplete Plugin calling

Posted by martinezgeovani on Stack Overflow See other posts from Stack Overflow or by martinezgeovani
Published on 2010-03-10T23:29:51Z Indexed on 2010/03/11 21:44 UTC
Read the original article Hit count: 404

Filed under:
|

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);
    }

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-autocomplete