I am accessing a json API and making an ajax call to get the json, I am successful in doing that but I want to populate the names from the json as suggested text under the textbox. I am having issues doing that. Can any one suggest some thing please?
$("#state").autocomplete({
source: function( request, response ) {
var result = $.ajax({
url: 'http://localhost:8181/jquery/api/states/regex?stateName='+request.term,
method: 'GET',
dataType: 'json',
success: function(data) {
//alert(data);
response($.map(data, function(item) {
//alert(item.stateName);
return {
label: item.stateName,
value: item.stateName
};
}));
}
});
return result.responseText;
},
minLength: 1
})
});
I got it working Thanks!!