Answer the question
In order to leave comments, you need to log in
jquery autocomplete how to set up?
I'm trying to set up jQuery Autocomplete, I wrote this code:
$("#name_input").autocomplete({
source: 'Home/MessageHandler',
minLength: 1,
select: function (event, ui) {
log("Selected: " + ui.item.value);
}
});
});
public JsonResult MessageHandler()
{
string result = "[{label:'string1',value:'string2'},{label:'string3',value:'string4'}]";
return Json(result);
}
Answer the question
In order to leave comments, you need to log in
The problem was that the controller did not give the correct json, rewrote it like this:
public IActionResult MessageHandler()
{
var result = new[] { @"ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++",
"Clojure", "COBOL", "ColdFusion", "Erlang","Fortran", "Groovy","Haskell",
"Java", "JavaScript", "Lisp", "Perl", "PHP", "Python","Ruby", "Scala", "Scheme" };
return Json(result);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question