Here is some PHP code that generates a json (javascript) object in response to a web service requestion. I'm not sure how to iterate over this object. I've looked at a lot of examples and they are in jQuery and don't deal the case (as mine does) of having sub-objects which I need to render in my select object.
Can anyone show me how to use a javascript object like this to populate a select list?
There are also sub objects with value indexs
data = object(
0 => object(
'label' = > 'test1',
'value' = > 1
),
1 => object(
'label' = > 'test1',
'value' = >
0 = > object(
'label' = > 'sub testing1',
'value' = > 1
),
1 = > object(
'label' = > 'sub testing2',
'value' = > 1
),
),
3 = > object(
'label' = > 'test3',
'value' = >
0 = > object(
'label' = > 'sub testing - test 3',
'value' = > 33
),
)
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…