I am trying to create an autocomplete window and there are problems due to the return of user data, I can not force it to fill in the autocomplete field.
This is the data (JSON):
[{"user_id":"1","user_name":"jarru"},{"user_id":"2","user_name":"harryq"},{"user_id":"3","user_name":"sleet"}]
And this is the javascript that I use:
<script type="application/javascript"> $(document).ready(function(){ $("#add_email_user").autocomplete({ source: baseurl+"users/ajax/users/", dataType: 'json', success: function(data) { console.log("asd"); response($.map(data, function(item) { return { label: item.user_name, value: item.user_id } })); } }); }); </script>
When I use this code, nothing happens, there is about 3px drop-down list in which there is nothing. Data is requested properly (as reported in the FireBug console), but nothing is populated in the drop-down list.
source share