我正在尝试使用 jquery 解析 json 对象,但它给了我无法获取空对象长度的错误。我无法找到原因。请帮助我找到问题。这是我在做什么
var slider_images = {
"image": [
{"fname":"1", "caption":"this is 1"},
{"fname":"2", "caption":"this is 2"},
{"fname":"3", "caption":"this is 3"},
{"fname":"4", "caption":"this is 4"},
{"fname":"5", "caption":"this is 5"},
{"fname":"6", "caption":"this is 6"},
{"fname":"7", "caption":"this is 7"},
{"fname":"8", "caption":"this is 8"}
]
};
var imageObj = $.parseJSON(slider_images.image);
$.each(imageObj,function() {
//alert("fname is::"+this['fname']);
alert("1");
});
我想获取图像下所有子对象的 fname 和标题。请让我知道我哪里出错了...
谢谢!