日期:2014-05-17  浏览次数:20654 次

jquery ajax select
$.ajax({
  type: 'POST',
  url: "${base}/smallLine/findSmallByBigLineId.do",
  data: "bigLineId="+bigLine,
  success: function(data){
  $("#smallLineId").empty();
  $("#smallLineId").html("");
  var options = "";
  for ( var i = 0; i < data.smallLinesList.length; i++) {
  var smallLine = data.smallLinesList[i];
  options+="<option value='"+smallLine.id+"'>"+smallLine.name+"</option>";
  }
  $("#smallLineId").append(options);
  $("#smallLineId").html(options);
  $("#smallLine").attr("style","");
  },
  dataType: "json"
});

------最佳解决方案--------------------
success: function(data){
                          $("#smallLineId").empty();
                        //  $("#smallLineId").html("");
                          var options = "";
                          for ( var i = 0; i < data.smallLinesList.length; i++) {
                              var smallLine = data.smallLinesList[i];
                              options="<option value='"+smallLine.id+"'>"+smallLine.name+"</option>";
                           $("#smallLineId").append(options);
                          }
                         
                         // $("#smallLineId").html(options);
                          $("#smallLine").attr("style","");
                      },
------其他解决方案--------------------


var options = "";
for ( var i = 0; i < data.smallLinesList.length; i++) {
 var smallLine = data.smallLinesList[i];
  options+="<option value='"+smallLine.id+"'>"+smallLi