I have the following code which is part of a autocomplete ajax query. My code returns a JSON it's working fine with the attached code, however I would like to use a variable in place of the item*.d_name* ie. I would like to make the auto complete function become more a boilerplate solution in which I can pass a variable to this function and it would substitute the item*.d_name*, with the variable's value. I am having difficulty in trying to figure out how to do this.
success: function(data) {
json = $.parseJSON(data);
response($.map(json, function(item) {
return {
label: item.d_name ,
value: item.d_name
};
}));
},