参考:https://www.cnblogs.com/ZkbFighting/p/8670087.html
获取 后台的list json 对象
1.格式化 data 的json 数据
var json= JSON.stringify(data);
2.转 json 数据
var a = eval(json);
3.遍历 json 对象
$.each(a,function(index,item){
$("#sc_category").append('<option value="'+ item.categoryName +'">' + item.categoryName + '</option>');
});
注意:为防止<select> 绑定的数据重复,在遍历前需要清空 <select>
$('#XXXXXXXXX').html('');
1.前台处理代码
$(function () {
getProductCategory();
});
function getProductCategory(){
$.ajax({
url: "/generalManager/getProductCategory", //后台url
type: "GET",
dataType: "json"