If you're still having this problem, I think it's because you're calling load_rss directly after you call google.load(...) . Then you're setting load_rss as your onload callback. So it's probably being fired twice. And the first time, it's likely throwing errors because the API hasn't had time to load yet.
Jeremy R. Geerdes Generally Cool Guy Des Moines, IA For more information or a project quote: [email protected] If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! On Jan 23, 2012, at 3:04 PM, Steven Huang wrote: > I'm getting a similar problem in that it seems my callback function > fires before google.load(...) finishes loading the library. I'm using > the http://code.google.com/apis/inapppayments/docs/tutorial.html#3 > API. > > On Jan 21, 9:57 am, Martine Osias <[email protected]> wrote: >> 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 onloadcallback. >> 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 -- 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
