1

I have some perfectly working code to fetch and parse an RSS feed that I want to put inside of a function but, since $.get is asynchronous I'm not able to return my array. What do I do wrong?

function parseRss(feed) {
    var items = [];
    $.get(feed, function (data) {
        $(data).find("item").each(function() { 
            var item = $(this);

            items.push({
                "title"     :  item.find("title").text(),
                "link"      :  item.find("link").text(),
                "image"     :  item.find("image").text(),
                "pubDate"   :  item.find("pubDate").text()
            });

        });
    });
    return items;
}
slwr
  • 1,105
  • 6
  • 16
  • 35
  • Possible duplicate of [How do I return the response from an asynchronous call?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Sarath Chandra May 16 '16 at 18:23

0 Answers0