我试图在我的项目中实现Facebook连接,并且它在90%的时间都有效。我正在运行以下代码启动FB SDK
<div class="alert alert-warning alert-dismissable">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Warning!</strong>
</div>
当它工作时,我的日志window.fbAsyncInit = function() {
// init the FB JS SDK
console.log("initing")
FB.init({
appId : app_id,
status : true,
xfbml : true
});
FB.getLoginStatus(function(response) {
console.log("getting login status", response)
if (response.status === 'connected') {
canEnter = 1;
var uid = response.authResponse.userID;
$.ajax
({
type: "POST",
url: siteurl+"/Introduction/ajax_facebook",
data: {'facebook_user_id': uid},
success: function(data)
{
}
});
}
});
};
会运行,但每次都不会被调用,当我点击使用Facebook按钮登录时,我收到错误console.log("getting login status", response)
。
FB.init似乎永远不会完成。为什么会这样?