I have the following JSON return
{"cliente":[
{"id":"1","nome":"Fulano"},
{"id":"2","nome":"Ciclado"}
]}
And I need my popular autocomplete
,
$('#nome').autocomplete({
source: function(request, response){
$.ajax({
url:"http://192.168.254.103:12514/web-parbs/htdocs/json/clientes.jsp",
dataType:"json",
success: function(data){
response($.map(data, function(item){
return {
label: item.id,
value: item.nome
};
}))
}})
}
});
This was one of the solutions I researched, the problem is that the item returns a Vector, I'm having trouble going in a way that stays label: the name of the client to be displayed in the field and the value: the id of the client. Can someone help me?