在选择框ajax-json中附加多维数组

时间:2015-07-03 10:10:19

标签: jquery ajax json

我的json回复:

char x = (char) ('a' + list.size() - 1);

我想在mySelect中用

显示json响应
[{"id":"1","color":"red","id_t":"1"},{"id":"3","color":"black","id_t":"1"}]

提前致谢!

1 个答案:

答案 0 :(得分:2)

success函数中尝试此操作: -

success: function( data ) {
  $('#mySelect').empty();
  $.each(data,function(i,d){
       $('#mySelect').append($('<option/>', {
           value: d.id,
           text: d.color
    }));
  });
}