Json Jquery每个循环

Json Jquery每个循环,jquery,json,Jquery,Json,出于某种原因,Jquery没有在Json数据中循环。当前未定义的错误 登录时使用Json。 { "cities": [ { "storename": "new Store", "notes": "test", "rejected": "on", "offer": "test" } ] } Html console.log(JsonData); $.e

出于某种原因,Jquery没有在Json数据中循环。当前未定义的错误

登录时使用Json。

{
    "cities": [
        {
            "storename": "new Store",
            "notes": "test",
            "rejected": "on",
            "offer": "test"
        }
    ]
}
Html

console.log(JsonData);

$.each($.parseJSON(JsonData), function(idx, obj) {
        alert(obj.storename);
});

对我来说,它看起来像一个对象,您还需要遍历cities属性

console.log(JsonData);

$.each(JsonData.cities, function (idx, obj) {
    alert(obj.storename);
});

对我来说,它看起来像一个对象,您还需要遍历cities属性

console.log(JsonData);

$.each(JsonData.cities, function (idx, obj) {
    alert(obj.storename);
});

您不再需要在此处解析jSON,因此可以使用:

$.each(JsonData.cities, function(idx, obj) {
     alert(obj.storename);
});

您不再需要在此处解析jSON,因此可以使用:

$.each(JsonData.cities, function(idx, obj) {
     alert(obj.storename);
});

我在错误的对象中循环,我的坏对象

 $.each($.parseJSON(JsonData), function(idx, cities) {
                          $.each(cities, function(idx, obj){
                           console.log(obj.storename)
                          });
    });

我穿过了一个错误的物体,我的坏东西

 $.each($.parseJSON(JsonData), function(idx, cities) {
                          $.each(cities, function(idx, obj){
                           console.log(obj.storename)
                          });
    });

很高兴它有帮助!快乐的编码伙伴:)很高兴它有帮助!快乐的编码伙伴:)