html代码
<select name="myid" id="myid" href="javascript:" >
<option>选择分类</option>
</select>
js代码:
window.onload = SearchVehicleTag();//加载页面时自动执行方法
function SearchVehicleTag(){
$.ajax({
url: “后台的地址”,
type: “post”,
dataType: “json”,
contentType: “application/json”,
traditional: true,
success: function (data) {
for (var i = 0; i < data.length; i++) {
var jsonObj =data[i];
$("#myid").append("" + jsonObj.TAGNAME + “”);
}
},
error: function (msg) {
alert(“数据加载出错,请重试!”);
}
});
}