I'm trying to return the image of an rss feed using the Google Feed API and Jquery
function parseRSS(url, location, container) {
$.ajax({
url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=5&callback=?&q=' + encodeURIComponent(url),
dataType: 'json',
success: function(data) {
//console.log(data.responseData.feed);
$(location).prepend('<h3>' + capitaliseFirstLetter(data.responseData.feed.title) + '</h3>').append('<ul id="rsslist"></ul>');
$.each(data.responseData.feed.entries, function(key, value) {
var thehtml =
'<li>' + value.title + '</li>' +
'<li>' + value.link + '</li>' +
'<li>' + value.image + '</li>';
$('#rsslist').append(thehtml);
});
}
});
}
function capitaliseFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
parseRSS('http://globoesporte.globo.com/Esportes/Rss/0,,AS0-9859,00.xml', '#teste', 'ul');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="container">
<div id="teste"></div>
</div>
But the part of the images only returns undefined, does anyone know to explain to me what I'm doing wrong?
If someone has the same question to control the number of iterations, just add if(key<1){
inside $ .each with return false; '