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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -