My guess is that initialize is actually being called, but it errors out on
the first line because google.feeds is undefined. The reason for this is
because of the way you're loading the Feeds API. Namely, you have it
loading in window.onload. window.onload is, for all practical purposes,
synonymous with google.setOnLoadCallback. So you're trying to utilize the
Feeds API at the same time you're trying to load the Feeds API. And worse,
when you use the loader to load the Feeds API without a callback parameter,
it will use document.write, which will probably result in your entire page
going blank.

To fix this, you need to make sure the order is correct. There are two
options for doing this, which I will outline below.

OPTION 1:
Locate these lines:

window.onload = function(){
google.load("feeds", "1");
}

and remove the first and third lines so that you are left with ONLY the
following:

google.load("feeds", "1");



OPTION 2:
Locate and remove the following line:

google.setOnLoadCallback(initialize);

Then, locate the following line:

google.load("feeds","1");

and alter it to read like this:

google.load("feeds","1",{"callback":initialize});



This second option is remarkable in that it will compel the Feeds API to
load asynchronously. This way, the rest of your page will render in full,
and then the Feeds API will load and call initialize when it's available.
The result is a perceived performance improvement (i.e., your page will
seem like it's loading faster when, in reality, it's just waiting to load
and do stuff related to the Feeds API).

jg



On Mon, Apr 1, 2013 at 8:52 AM, <joao.pedro....@gmail.com> wrote:

> It seems that the initialize never start. Why?
>
> <html>
>   <head>
>     <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
>     <script type="text/javascript">
> window.onload=function(){
>     google.load("feeds", "1");
> }
>     function initialize() {
>       var feed = new google.feeds.Feed("feed://
> g1.globo.com/dynamo/tecnologia/rss2.xml");
>       feed.load(function(result) {
>         if (!result.error) {
> alert("hi");
>           var container = document.getElementById("feed");
>           for (var i = 0; i < result.feed.entries.length; i++) {
>             var entry = result.feed.entries[i];
>             var div = document.createElement("div");
>             div.appendChild(document.createTextNode(entry.title));
>             container.appendChild(div);
>           }
>         }
>       });
>     }
>     google.setOnLoadCallback(initialize);
>
>     </script>
>   </head>
>   <body>
>     <div id="feed"></div>
>   </body>
> </html>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Google AJAX APIs" group.
> To post to this group, send email to
> google-ajax-search-api@googlegroups.com
> To unsubscribe from this group, send email to
> google-ajax-search-api+unsubscr...@googlegroups.com
> To view this message on the web, visit
> https://groups.google.com/d/msg/google-ajax-search-api/-/tGXLXv6-CGgJ
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to google-ajax-search-api+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Jeremy R. Geerdes
Generally Cool Guy
Des Moines, IA

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan
Church!
http://www.debraheightswesleyan.org

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
google-ajax-search-api@googlegroups.com
To unsubscribe from this group, send email to
google-ajax-search-api+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to google-ajax-search-api+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to