简体   繁体   English

jQuery将RSS提要限制为4个项目

[英]JQuery limits RSS feed to 4 items

I have this code that I am using to import an RSS feed via JQuery. 我有用于通过JQuery导入RSS feed的这段代码。 My problem is that it only imports 4 RSS items and then stops. 我的问题是,它仅导入4个RSS项目,然后停止。 Any idea why this might be? 知道为什么会这样吗?

$.fn.rssWidget = function(feedUrl, dateFormat){
var dateFormatF = dateFormat || 'day/month/year hours:minutes';
var googleFeedUrl = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0';
var title = '<h4 class="rsswidget-feed" style="display:none;"><a href=":url">:title</a></h2>';
var item = '<hr/><h5 class="rsswidget-title" style="display:none;"><a href=":url">:title</a></h3><p class="rsswidget-date" style="display:none;">:date</p><div class="rsswidget-content">:text</div>';
$(this).each(function(){
    var $that = $(this);
    var feed = $(this).attr('feed') || feedUrl;
    feed = encodeURIComponent(feed);
    $.getJSON(googleFeedUrl
        + '&q=' + feed
        + '&callback=?'
        ,function(d){
            var f = d.responseData.feed;
            console.log(f);
            $that.html(title.replace(':url', f.link).replace(':title', f.title));
            $(f.entries).each(function(i,e){
                var date = new Date(e.publishedDate);
                var dateString = dateFormatF
                .replace('day', date.getDate() < 9 ? '0' + date.getDate() : date.getDate())
                .replace('month', (date.getMonth() + 1) < 9 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
                .replace('year', date.getFullYear())
                .replace('hours', date.getHours() < 9 ? '0' + date.getHours() : date.getHours())
                .replace('minutes', date.getMinutes() < 9 ? '0' + date.getMinutes() : date.getMinutes())
                ;
                $that.append(item
                    .replace(':title', e.title)
                    .replace(':url', e.link)
                    .replace(':text', e.content)
                    .replace(':date', dateString));
            });
        });
});

And then I drop this into my HTML 然后将其放入HTML

<script type="text/javascript">
            $(function(){
              $("div#feed").rssWidget('RSS FEED URL');
            });
            </script>
                <div id="feed"></div>

切换到YPL并按照此处的文档寻求解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM