데이터 객체가 있고 내부에 json 데이터가있는 데이터 객체가 있습니다. 다음은 어떻게 생겼는지입니다. 파일의 이름은 여기jsonery for for 루프를 사용하여 json 데이터를 읽을 수 없습니다.
var data =
[
{
title: 'this is title one',
commit: 'this is commit'
},
{
title: 'this is title two',
commit: 'this is commit'
},
{
title: 'this is title three',
commit: 'this is commit'
},
{
title: 'this is title four',
commit: 'this is commit'
},
{
title: 'this is title five',
commit: 'this is commit'
},
{
title: 'this is title six',
commit: 'this is commit'
},
{
title: 'this is title seven',
commit: 'this is commit'
}
]
data.js
내가 오류 위
Cannot read property 'title' of undefined
이 줄에 내 콘솔에서이 오류를 얻고있다 이제 내 코드
for (var i = 0; i < data.length; i++) {
$(container).load(view, function() {
console.log(data[i].title);
li.append('<img src="../images/profile.png" alt="Profile photo" />');
li.append('<span class="commit">' + data[i].title + '</span>');
li.append('<p><a href="#" class="comment">' + data.commit + '</a></p>');
li.append('<section class="clear"></section>');
$('#home ul').append(li);
});
}
입니다
li.append('<span class="commit">' + data[i].title + '</span>');
이것을 고치는 방법?