jquery - convert array from inside of returned object into select item list js -
i've looked @ several examples here on how , answer still alludes me.
i have ajax call returns object couple properties array of other objects. want take 2 properties each internal object create list. right now, have code looks this:
mymethod: function(data){ $.each(data, function(){ $('#myselectlist').append($('<option></option>').text(data.name).val(data.id)); }); }
i have tried json.stringify(data.name)
well, believe needed here, think accessing properties incorrectly. object returned looks in chrome dev tools:
object {booleanproperty1: true, booleanproperty2: true, rows: array[9]}
and when drill down rows:
0: object id: 1 title: "sometitle" someotherproperties: propertydata //more properties 2: object id: 2 title: "someothertitle" someotherproperties: propertydata //more properties //more objects
how can access properties inside array use them when creating list?
data
it's response or complete array , need each of elements inside of it, need specify index , element
parameters in function , read values element
$.each(data.rows, function(index, element){ $('#myselectlist').append($('<option></option>').text(element.name).val(element.id)); });
Comments
Post a Comment