[英]Log in works fine, but now no functions can be called
Here is my code that starts right below the opening body tag: 这是我的代码,该代码从开始body标签下面开始:
<div id="fb-root"></div>
<script>
alert("made it into the script");
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '360348567392858', // App ID from the App Dashboard
channelUrl : 'http://chrisvanhorne.com/users/erosas/final/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// User logged into FB and authorized
testAPI();
document.getElementById('fb-logout').style.display = 'block';
} else if (response.status === 'not_authorized') {
// User logged into FB but not authorized
login();
} else {
// User not logged into FB
login();
document.getElementById('fb-logout').style.display = 'block';
}
});
};
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
alert("made it to login");
testAPI();
} else {
// cancelled
}
});
}
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
}
// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
</script>
The log in function works fine, but afterwards no calls can be made to functions within this script tag. 登录功能可以正常工作,但此后无法对该脚本标记内的函数进行任何调用。 Not only that, but oddly enough no
<script>
's with javascript in them work at all after the Facebook script code. 不仅如此,但奇怪的是,没有javascript的
<script>
在Facebook脚本代码之后根本无法工作。 None of the debug alert() functions are called and no calls are made(that I can tell to Facebook). 没有调用debug alert()函数,也没有进行任何调用(我可以告诉Facebook)。
Some possible issues I've considered, but am unsure about: 我已经考虑过一些可能的问题,但是不确定:
Any help would be greatly appreciated as I am currently going crazy trying to figure this out, thanks! 任何帮助将不胜感激,因为我目前正在努力解决这个问题,谢谢!
Unbelievable, it was in part due because the code wasn't waiting for the init function to complete and because there were "bad" javascript tags in the head(not shown) that ended as: rather than . 令人难以置信,部分原因是代码没有等待init函数完成,并且因为头部(未显示)中有“坏的” javascript标记,结尾为:而不是。 Easy fix, will search harder for answers next time
易于修复,下次将更加努力地寻找答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.