access ajax data in closure
<p>I want to populate a "private" variable in my function with some data loaded by ajax, so it can be accessed within the function. What I currently have:</p>

<pre><code>var foo = (function(){

    var ajaxData;

    var useAjaxData = function(data){

    };

})();
</code></pre>

<p>I suppose that I need to do something similar to this, since it's an async call? Are there any prettier solutions for this?</p>

<pre><code>var foo = (function(){

    $.ajax({
       url: 'something',
       success: function(data){

           var ajaxData = data;

           var useAjaxData = function(data){

           };
      }
    });

})();
</code></pre>
