1. 程式人生 > >ajax 遍歷select 下拉框

ajax 遍歷select 下拉框

bsp erro string rip sig not context () cati

html :<select id="type" > </select>

js代碼:

<script type="text/javascript">
//動態綁定下拉框項
function addnotice() {
$.ajax({
url: "${pageContext.request.contextPath}/dictionary/jindex.action?sign=4", //後臺返回json數據
type: "post",
dataType: "json",
contentType: "application/json",
traditional: true,
success: function (data) {
for (var i in data) {
var jsonObj =data[i];
var optionstring = "";
for (var j = 0; j < jsonObj.length; j++) {
optionstring += "<option value=\"" + jsonObj[j].name + "\">" + jsonObj[j].name + "</option>";
$("#type").html("<option value=‘請選擇‘ >請選擇...</option>"+ optionstring);
}


}
},
error: function (msg) {
alert("出錯了!");
}
});
};
window.onload=addnotice; //頁面加載完自動加載
</script>

ajax 遍歷select 下拉框