我需要知道,如果我有这样的回复,我怎么能提取数据
Object {cast: Object}
cast: Array[5]
0: Object
text: "Select Any"
value: "000"
__proto__: Object
1: Object
2: Object
3: Object
4: Object
在剩余对象中使用相同的模式
更新1
我有这样的数组
var response = {};
response = showData();
当我console.log(response)
时
然后在我的控制台中将显示上面提到的输出
当我尝试response.length
时,它会显示undefined
更新2
function showData(){
var foodSubCatagories1 = {};
foodSubCatagories1.cast = _context.FoodGroup.forEach(function(FG)
{
$('#selectCatagoryFood').append('<option value="'+FG.FoodGroupID+'">'+FG.Description+'</option>');
}).then(function(){
$('#selectCatagoryFood').selectmenu('refresh');
foodSubCatagories1.cast = [
{
value: "000",
text: "Select Any"
},
{
value: "1",
text: "Juice"
},
{
value: "2",
text: "Dairy"
},
{
value: "3",
text: "Farm"
},
{
value: "4",
text: "Custom"
}
];
return foodSubCatagories1.cast;
});
return foodSubCatagories1;
}
答案 0 :(得分:0)
for ( var c in response.cast )
{
console.log ( c ); // array item
console.log ( c.text); // item propery
}