-1

我需要知道如果我有这样的响应,我该如何提取数据

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;

}

4

1 回答 1

0
    for ( var c in response.cast ) 
    {
    console.log ( c ); // array item 
  console.log ( c.text); //  item propery 
    }
于 2013-10-03T20:07:41.727 回答