jQuery UI autocomplete with objects

The problem was Autocomplete couldn’t render the source for its functioning.

You need to set the source of the autocomplete based on the JSON data present using ,

source: function (request, response) {
           //data :: JSON list defined
           response($.map(data, function (value, key) {
                return {
                    label: value.first_name,
                    value: value.id
                }
            }));
        
    },

And, I also removed the .data callback from the code.

See the working code here

Leave a Comment