Hi, I'm loading multiple feeds asynchronously and rendering the
results in separate elements of the DOM as they are returned from the
Feeds API. Basically I'm trying to achieve something similar to the
callback+context behavior mentioned at the end of the section
http://code.google.com/apis/ajaxfeeds/documentation/#fonje
but just using the Javascript API.
I noticed that this context index is the first parameter in the call
to the JSONP function google.feeds.Feed.RawCompletion returned by the
Feeds API. But instead of just using the internally incrementing value
I'd like to use my own, so that I can reference it inside of the
callback function and display the results in the correct places on the
page.
Here's a simple example, trying to emulate the extra parameter
mentioned in the docs:
//<![CDATA[
var urls = { 'digg':"http://www.digg.com/rss/index.xml",
'google':"http://www.google.com/base/feeds/snippets"};
function main() {
for (var i in urls) {
var feed = new google.feeds.Feed(urls[i]);
feed.load( function(result, context){
// callback:
if (!result.error) {
console.log('Feed contains
'+result.feed.entries.length + '
posts');
console.log('local context is ',context); //
undefined
}
}, i); // pass the strings 'digg', 'google' as trivial
"contexts"
}
}
google.load("feeds", "1");
google.setOnLoadCallback( main );
//]]>
Can somebody please point me in the right direction?
thanks
Klokie
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---