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