title: return value from getJSON function
body: <p>I have a function with jquery getJSON and i need the return the result value back (to Use it somewhere else)</p>
  
  <p>Here is the code:</p>
  
  <pre><code>function getval(){
  jQuery.getJSON('http://data.mtgox.com/api/1/BTCUSD/ticker?callback=?', function(data) {
      // We can't use .return because return is a JavaScript keyword.
      return data['return'].avg.value;
  });
  }
  
  $(function () {
      $(document).ready(function() {
      alert (getval());
      });
  
  });
  </code></pre>
  
  <p>This is doesn't work :(</p>
  
  <p><strong>i know i can call external function from inside the getJSON function with the value like:</strong></p>
  
  <pre><code>    jQuery.getJSON('http://data.mtgox.com/api/1/BTCUSD/ticker?callback=?', function(data) {
          // We can't use return because return is a JavaScript keyword.
         mysecondfunction(data['return'].avg.value);
      });
  function mysecondfunction(value){
  //use the value
  }
  </code></pre>
  
  <p>But i have to call the <strong>json</strong> function from <strong>another</strong> function because json return a dynamic value and i need to use it.</p>
  
  <p>I hope it clear... </p>
  
  <p><strong>Thank you very much!!</strong></p>