Changing external variable from nested function
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/9041321/return-ajax-callback-return">return AJAX callback return</a>  </p>
</blockquote>



<p>Running the below code:
res1 is full,
res2 is empty,
res3 is empty,</p>

<p>How can i change the result variable and use it as return of the most out function</p>

<pre><code>function fillusers() {
    var result = '';
    $.when(
    $.getScript("http://localhost:9090/app/dwr/engine.js"), $.getScript("http://localhost:9090/app/dwr/util.js"), $.getScript("http://localhost:9090/app/dwr/interface/myService.js"), $.Deferred(function(deferred) {
        $(deferred.resolve);
    })).done(function() {
        myService.getUsers({
            callback: function(str) {
                result = jQuery.parseJSON(str);
                console.log('res1' + result);
            }
        });
        console.log('res2' + result);
    });
    console.log('res3' + result);

    return result;
}​
</code></pre>
