Load RSS data into global variable
<p>I use Javascript. I want to get RSS data by API google (this link: <a href="http://www.javascriptkit.com/dhtmltutors/googleajaxfeed.shtml" rel="nofollow">http://www.javascriptkit.com/dhtmltutors/googleajaxfeed.shtml</a> ), then insert the data into a Array (<em>Global variable</em>). But my global variable can not save data.</p>

<p>Inside <strong>rssfeedsetup()</strong> function, ARR_DATA (<em>Global Array</em>) have data. However, after load <strong>rssfeedsetup()</strong> function, ARR_DATA have no data. </p>

<p>Please show me, how to insert data to global variable in this case.</p>

<p>My code: 
Head:</p>

<pre><code>&lt;head&gt;
    &lt;title&gt;TEST API FEED RSS&lt;/title&gt;

    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;

    &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;
    &lt;/script&gt;

    &lt;script type="text/javascript"&gt;
        google.load("feeds", "1"); //Load Google Ajax Feed API (version 1)
    &lt;/script&gt;
&lt;/head&gt;
</code></pre>

<p>Body: </p>

<pre><code>&lt;body&gt;
    &lt;div id="feeddiv"&gt;&lt;/div&gt;

    &lt;script type="text/javascript"&gt;

        var ARR_DATA = []; // **I want to insert data into this array**

        var feedurl = "http://rss.slashdot.org/Slashdot/slashdot";
        var feedlimit = 4;

        function rssfeedsetup() {
            var feedpointer = new google.feeds.Feed(feedurl); //Google Feed API method
            feedpointer.setNumEntries(feedlimit); //Google Feed API method
            feedpointer.load(displayfeed); //Google Feed API method
        }

        function displayfeed(result) {
            if (!result.error) {
                var thefeeds = result.feed.entries;
                var arr_Temporary = [];

                for (var i = 0; i &lt; thefeeds.length; i++) {

                    arr_Temporary[0] = thefeeds[i].title;
                    arr_Temporary[1] = thefeeds[i].link;

                    // insert RSS data into ARR_DATA.
                    ARR_DATA.push(arr_Temporary);

                    console.log('value before:', ARR_DATA); // check value of ARR_DATA, there have data exist.
                }
            } 
        }

        window.onload = function () {
            rssfeedsetup(); // call function

            console.log('value2 after:', ARR_DATA);  // check value of ARR_DATA, there is no data.
        };
        console.log('value2 after:', ARR_DATA); //check value of ARR_DATA, there is no data.
    &lt;/script&gt;
&lt;/body&gt;
</code></pre>

<p>I have got value console:
<a href="http://i.stack.imgur.com/qYw16.jpg" rel="nofollow">image of firebug on firefox</a></p>

<p>Ps: Why ARR_DATA no contain data after load function rssfeedsetup()?</p>