I'm trying to create an auto-complete box and have been having problems due to returning custom data, I cannot seem to get it to populate the autocomplete box.
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 I'm using:
<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 a 3px dropdown with nothing in it. The data is being requested properly (as reported by FireBug console) but nothing is populated into the dropdown.