javascript - Print a specific attribute from an object within an AJAX retrieved object list? -


i'm using ajax call return list of objects database in json format. these displayed part of autocomplete text input. problem want output/display name attribute of each object within list.

$(function() {     $("#ingredient-search").autocomplete({         source : function(request, response) {             $.ajax({                 url : "searchcontroller",                 type : "get",                 data : {                     term : request.term                 },                 datatype : "json",                 success : function(data) {                     response(data);                 }             });         }     }); 

the actual ajax & on works fine. i'm unsure how can iterate through every element within 'data' , output name attribute each json object.

thanks

without knowing json structure, try this.

$.each(data,function(key,val){     console.log(val.name); }) 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -