title: How to create jquery ajax as separate function?
body: <p>I want to create a separate function to get specific data from Facebook graph JSON.
  For example, I have the load() and called getNextFeed() function.</p>
  
  <p>The getNextFeed works correctly. Except that returning value of aString is not successful. 
  When I pop alert(thisUrl). It said undefined. </p>
  
  <p>Note: I am new to Javascript and Jquery. Please give me more information where I did wrong. Thank you.</p>
  
  <pre><code>    function load()
      {
  
           $(document).ready(function() {
           var token = "AccessToken";
           var url = "https://graph.facebook.com/me/home?access_token=" + token;      
            var thisUrl = getNextFeed(url);
           alert(thisUrl); // return undefined
      });
  
  
  
  
      function getNextFeed(aUrl)
      {   
            $.ajax({
             type: "POST",
             url: aUrl,
             dataType: "jsonp",
             success: function(msg) {
             alert(msg.paging.next); // return correctly
  
              var aString = msg.paging.next;
              alert(aString); // return correctly
              return aString;
  
             }
          });
       }
  </code></pre>