1
I have the following return JSON
{"cliente":[
{"id":"1","nome":"Fulano"},
{"id":"2","nome":"Ciclado"}
]}
And I need popular man 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 problems to go through in a way that stays label: the name of the client to be displayed in the field and value: the customer id. Can someone help me?
Why don’t you call the
$.map
passing bydata.cliente
instead ofdata
? In fact the result of$.map
this correct.– Wakim
Man, that’s all it was, I did so much research and I didn’t see that mistake. Anyway, thanks for your attention!
– Rodrigo Wippel