title: Getting variable out of a get ajax call
body: <p>This problem is actually caused by my not fully understanding jquery.</p>
  
  <p>I have some code that i tried to put in a function to use multiple times.</p>
  
  <pre><code>function actors(query){
      $.get("websit.com?title=" + query + "&amp;type=json", function(html){
          var result = html;
          var obj = eval ("(" + result + ")");
          var actor = obj[0].actors;
          return actor; //as far as im aware this does nothing
      });
      return 0; // gets here and returns zero, returning actor here returns undefined
  }
  </code></pre>
  
  <p>The actor variable holds the information i need, however I'm struggling to get the variable out of the function.
  Because of the inner function it will run through and get to the <code>return 0;</code></p>
  
  <p>If i try assign a variable to the inner function it will return an object and not the return variable.</p>
  
  <p>Any solutions or pointers in the right direction would be greatly appreciated.</p>