On this page where I show RSS feeds with the Google API there is an
initialization problem. When the page loads the news items aren't
show. If I refresh the page, then they are.

I have this in the HTML.

<div id="snews" style="position:relative; width: 100%; height: 100%;
overflow-y: auto; overflow-x: hidden;">
    <div id='feed-control'>
       <span style='color:#676767;font-size:11px;margin:10px;padding:
4px;'>Loading...</span>
    </div>

        <script type='text/javascript'>
        // Load the feeds API and set the onload callback.
        google.load('feeds', '1');
            load_rss("http://www.catholicnewsagency.com/rss/
news.xml");
        google.setOnLoadCallback(load_rss);
    </script>
</div> <!-- End snews -->

The Google api calls to load the news items are in that function.

// Load RSS
function load_rss(url) {
    google.load("feeds", "1");
    var feed = new google.feeds.Feed(url);
    var entry_target = "viewer";
    /*************************************
    Feed Title       feed.title
    Feed Link        feed.link
    Feed Description feed.description
    Feed Author      feed.author
    Feed Entries     feed.entries[]
    Entry Title      feed.title
    Entry Link       feed.link
    Entry Content    entry.content
    Content Snippet  entry.contentSnippet
    Published Date   entry.publishedDate
    Categories       entry.categories[]
    **************************************/
    feed.setNumEntries(10);
    feed.load(function(result) {
        $('#feed-control').append('<table id="rssentries"></table>');
        if (!result.error) {
          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
            var entrydate = new Date(entry.publishedDate);
            var entry_yr  = entrydate.getFullYear();
            var entry_mon = entrydate.getMonth()+1;
            if (parseInt(entry_mon) < 10 ) { entry_mon =
"0"+entry_mon; }
            var entry_day = entrydate.getDate();
            if (parseInt(entry_day) < 10 ) { entry_day =
"0"+entry_day; }
            var entry_date= entry_mon + "." + entry_day + ': ';
            $('#rssentries').append('<tr><td>'+entry_date+'<a
href="'+entry.link+'" target="'+entry_target+'"
onclick="show_title(\''+escape(entry.title)+'\');">'+entry.title+'</
a></td></tr>');
          }
        }
    });
}

What should I fix in that code for the news items to show the first
time around?

-- 
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
To view this message on the web, visit
http://groups.google.com/group/google-ajax-search-api?hl=en_US
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en

Reply via email to