0
I am 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>
<div class="container">
<div id="teste"></div>
</div>
But the part of the images only returns Undefined, someone can explain me what I’m doing wrong?
If someone has the same question to control the number of iterations just add one if(key<1){
within $.each with Return false;`
can you give me a hint on how to manipulate the amount of feeds that will appear? Since $each goes through all entries
– haykou
Conditions the value of key from the first jQuery.each() with some value and if the test returns true you give a
return false;
– Bruno Augusto
I’ll update the question, it worked :)
– haykou
I will correct your editing. It’s not before, it’s inside. p
– Bruno Augusto