Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook 在页面显示中使用getLoginStatus时未定义FB_Facebook_Jquery Mobile - Fatal编程技术网

Facebook 在页面显示中使用getLoginStatus时未定义FB

Facebook 在页面显示中使用getLoginStatus时未定义FB,facebook,jquery-mobile,Facebook,Jquery Mobile,我没有定义FB,当我写下面的代码时,我已经使用window.fbAsyninit成功地为facebook添加了必要的文件,问题是如果我在“单击”事件下写下面的代码,那么它工作得很好,但在jquery mobile中的pageshow时没有。这可能是因为facebook js文件加载有点晚。但是我想检查每个页面上的用户状态,以限制不必要的或匿名的访问 $("#details").live( "pageshow", function() { FB.getLoginStatu

我没有定义FB,当我写下面的代码时,我已经使用window.fbAsyninit成功地为facebook添加了必要的文件,问题是如果我在“单击”事件下写下面的代码,那么它工作得很好,但在jquery mobile中的pageshow时没有。这可能是因为facebook js文件加载有点晚。但是我想检查每个页面上的用户状态,以限制不必要的或匿名的访问

$("#details").live( "pageshow", function() {

            FB.getLoginStatus(function(response) {
              if (response.status === 'connected') {
                // the user is logged in and connected to your
                // app, and response.authResponse supplies
                // the user's ID, a valid access token, a signed
                // request, and the time the access token 
                // and signed request each expire
                var uid = response.authResponse.userID;
                var accessToken = response.authResponse.accessToken;

                console.log("INSIDE ME");
              } else if (response.status === 'not_authorized') {
                // the user is logged in to Facebook, 
                //but not connected to the app
                console.log("OUTSIDE ME");
              } else {
                // the user isn't even logged in to Facebook.
              }
        });

 });
将jQuery live()赋值也放在window.fbAsyninit中。因此,只有在FB有机会初始化之后,它才会应用于DOM元素