<script>
$(document).ready(function () {
init();
function init(){
$.ajax({
type: "get",
url: "http://f004f6ad.ngrok.io/usercenter/clazz/getClazz",
dataType: "json",
success: function (data) {
for(var i in data){ //拿到的是数组,要遍历每个对象,然后插入select表单
$("#inClazz").append("<option value="+data[i].id+">"+data[i].name+"</option>");
}
getUserByClazzId();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
})
}
});
</script>
<select name="clazz" id="inClazz" onload="init()"></select>