ajax动态给select赋值
<select name="elements" id="ele" style="width: 145px;">
</select>
function for_elements(){
$.ajax({
url : 'selectElements',
data : {
},
dataType : 'json',
success : function(s) {
var datas=s.obj;
var optionstring = "";
for (var j = 0; j < datas.length; j++) {
optionstring += "<option value=\"" + datas[j].name + "\" >" + datas[j].name + "</option>";
}
$("#ele").html("<option value=''>全部</option> "+optionstring);
}
});
}