if (result.success) {
var obj = JSON.parse(result.data);
var sltObj = document.getElementById("selUser"); //获取select对象
for (var i = 0; i < obj.length; i++) {
var optionObj = document.createElement("option"); //创建option对象
optionObj.value = Object.keys(obj[i]); //获取属性名称
optionObj.innerHTML = obj[i][Object.keys(obj[i])];//获取属性名称的值
sltObj.appendChild(optionObj); //添加到select
}
console.log(result.data);
}
else {
layer.msg(result.data);
var sltObj = document.getElementById("selUser"); //获取select对象
sltObj.options.length = 0;
}
for(variable in test001){ //variable 为属性名
console.log(variable) //name age
}