当前位置: 代码迷 >> Java Web开发 >> jquery ajax select解决方法
  详细解决方案

jquery ajax select解决方法

热度:5381   发布时间:2013-02-25 21:07:48.0
jquery ajax select
$.ajax({
  type: 'POST',
  url: "${base}/smallLine/findSmallByBigLineId.do",
  data: "bigLineId="+bigLine,
  success: function(data){
  $("#smallLineId").empty();
  $("#smallLineId")("");
  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")(options);
  $("#smallLine").attr("style","");
  },
  dataType: "json"
});

------最佳解决方案--------------------------------------------------------
success: function(data){
                          $("#smallLineId").empty();
                        //  $("#smallLineId")("");
                          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")(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+"'>"+smallLine.name+"</option>";
  相关解决方案