title: Javascript callback - how to return the result?
body: <p>I am struggling to totally understand callbacks and i am stumbling at the final hurdle.</p>
  
  <p>Within JS I am calling a function which then calls a PHP function using a dojo rpc Json Service. I have stepped through the function in firebug and the PHP is executing and returning me the correct response via the callback but I don’t know how to return the value to the initial JS variable that invoked the JS function? E.g.</p>
  
  <pre><code>JS Function 1
  
  Function one(){
  
  Var test = getPhp(number);
  
  }
  
  function getPhp(number)
  {
  
  this.serviceBroker = new dojo.rpc.JsonService(baseUrl + '/index/json-rpc/');
  
      var result = serviceBroker.phpFunc(number);
  
      result.addCallback(
          function (response)
          {
              if (response.result == 'success')
              {
                  return response.description;
                 //I am trying to pass this value back to the 
                 //var test value in   function one
  
              }
          }
      );
  }
  </code></pre>
  
  <p>Basically i now need to pass response.description back to my var test variable in function one. </p>
  
  <p>Any help is appreciated</p>