Problem appending options to a select from a JSON object
I have this Json from a $.getJson function:
[
{"UserName":"Z1","FullName":"XY1"},
{"UserName":"Z2","FullName":"XY2"},
{"UserName":"Z3","FullName":"XY3"}
]
I try to append these into options of a select tag as a pair of value end text. I've tried this:
$.each(data, function(i,item) {
alert(item.UserName + " " + item.FullName);
});
but it gave me: undefined undefined
.
I think it should work. What's wrong?
Seems to be working fine here: http://jsfiddle.net/maniator/ZKBYU/
精彩评论