0
Google API에서 데이터를 표시하려고하지만 계속 결과가 "정의되지 않음"으로 표시됩니다. 여기 내 코드는 다음과 같습니다Google API Json Ajax/Jquery Call
$(document).ready(function() {
var url='https://www.googleapis.com/books/v1/volumes?q=harry+potter&maxResults=9'
$('#button').click(function() {
$.getJSON(url,function(data){
$('#content').empty();
$.each(data.items, function(entryIndex, entry){
var html = '<div class="result">';
html += '<h3>' + entry.id + '</h3>';
html += '<div class="title">' + entry.volumeInfo.title + '</div>';
html += '<div class="author">' + entry.volumeInfo.authors + '</div>';
$('#content').append(html);
});
});
return false;
});
});
문제는 루프 만 한 행을 계산 한 것이 었습니다 :로 보일 것입니다
$(document).ready(function() {
var url='https://www.googleapis.com/books/v1/volumes?q=harry+potter&maxResults=9'
$('#button').click(function() {
$.getJSON(url,function(data){
$('#content').empty();
$.each(data, function(entryIndex, entry){
var html = '<div class="result">';
html += '<h3>' + entry['id'] + '</h3>';
html += '<div class="title">' + entry['title'] + '</div>';
html += '<div class="author">' + entry['author'] + '</div>';
$('#content').append(html);
});
});
return false;
});
});
도움 주셔서 감사합니다. 하지만 여전히 작동하지 않는 것 같습니다 : http://pixeloft.com/clients/popdust/ – user2140126
사이트의 Javascript 콘솔에서 샘플을 직접 수행 한 후 문제에 대한 해결책을 제공하기 위해 답을 편집했습니다. –
이 작품! 정말 고맙습니다! – user2140126