Store ajax data into a global variable
<p>Continuing with <a href="http://stackoverflow.com/questions/905298/jquery-storing-ajax-response-into-global-variable">JQuery - Storing ajax response into global variable</a></p>

<p>Accepted solution somehow does not work for me.</p>

<pre><code>$(document).ready(function() {
    var dataStore = (function(){
        var xml;

        $.ajax({
          type: "GET",
          url: "/?do=getcontentadm1n&amp;category=homepage",
          dataType: "json",
          success : function(data) {
                        xml = data.html;
                alert(xml); // WORKS
                    }
        });

        return {getXml : function()
        {
            if (xml) return xml;
        }};
    })();

    var somevar = dataStore.getXml();

    alert(somevar); // UNDEFINED
});
</code></pre>

<p>Is there other solution?</p>

<p>Thanks.</p>
