简体   繁体   中英

json and jquery autocomplete - need help to understand what is wrong?

 <form action="" method="get" style="margin-left: 2em"> <input id="companies" type="text" name="company" value="" size="40" /> <button type="submit" class="button-search">Search</button> </form> 

my json comes from this

http://localhost:8080/;companies?name=aba

and returns a valid json like:

{"name": "aba", "title": "Aba"}, {"name": "abak", "title": "Abak"}]

<script language="javascript">
$(function() {
  $("#companies").autocomplete({
    source: ";companies",
    minLength: 2,
    select: function(event, ui) {
      // perhaps do something with these?
      name = ui.item.name;
      title = ui.item.title;
   }
});
});
</script>

i get no results in the list being displayed!

what am i missing here?

thanks

According to the jqueryui autocomplete doc/demo , the url parameter is "term", not "name".

So, http://localhost:8080/;companies?term=aba should return the expected json, instead of http://localhost:8080/;companies?name=aba which you're using now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM