javascript - Unable to pass a response form facebook to another function -


if view question thank in advance!, working on pulling data facebook.

i trying pull username facebook can use in later stage have embedded following code in fb root div.

i know retrieve works! not able pass on function returndata relative new javascript please me out? have tried

there alert in there check if retrieving data

<div id="fb-root"></div> <script type="text/javascript">       $(document).ready(function()      {         var appid = "121070974711874";          // if logging in facebook canvas application use url.         var redirecturl = "http://apps.facebook.com/bggressive";          // if logging in website this. sure add host           application's app domain list.          var redirecturl = window.location.href;          // if user did not grant app authorization go ahead , tell them that. stop code execution.         if (0 <= window.location.href.indexof ("error_reason"))         {              $(document.body).append ("<p>authorization denied!</p>");              return;         }          // when facebook sdk script has finished loading init        // sdk , login status of user. status        // reported in handler.        window.fbasyncinit = function()        {            fb.init({                      appid : appid,                      status : true,                      cookie : true,                      oauth : true            });            fb.getloginstatus (oncheckloginstatus);        };         (function(d)        {           var js, id = 'facebook-jssdk'; if (d.getelementbyid(id)) {return;}           js = d.createelement('script'); js.id = id; js.async = true;           js.src = "//connect.facebook.net/en_us/all.js";           d.getelementsbytagname('head')[0].appendchild(js);        }(document));          function oncheckloginstatus (response)        {           if (response.status != "connected")           {               top.location.href = "https://www.facebook.com/dialog/oauth?client_id=" + appid + "&redirect_uri=" + encodeuricomponent (redirecturl) + "&scope=user_photos,friends_photos";           }           else           {               fb.api('/me', function(response)                {                   pason = response.username                   alert(response.username)               });           }        }    });     function returndata()    {       = pason       return    };  </script> 

i think calling function returndata() @ random point can't do. reason is- variable pason assigned value asynchronously. so, have code in such way call returndata() after value assigned!

its not quite clear trying function returndata(). but, hope concept clear now.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -