Javascript 在Django应用程序中实现Facebook注销时出现FB未定义错误

Javascript 在Django应用程序中实现Facebook注销时出现FB未定义错误,javascript,python,html,django,facebook,Javascript,Python,Html,Django,Facebook,我试图为我的django应用程序实现facebook注销功能。在我的应用程序中,用户可以使用应用程序用户名或FB用户名登录。现在我还想实现注销功能。 为了做到这一点,我把这段代码放在我的html页面中,但我得到了“FB未定义”错误。有人能帮我解决这个问题吗 <html xmlns:fb="http://www.facebook.com/2008/fbml"> <div id="fb-root"></div> <script src="http://c

我试图为我的django应用程序实现facebook注销功能。在我的应用程序中,用户可以使用应用程序用户名或FB用户名登录。现在我还想实现注销功能。 为了做到这一点,我把这段代码放在我的html页面中,但我得到了“FB未定义”错误。有人能帮我解决这个问题吗

<html xmlns:fb="http://www.facebook.com/2008/fbml">
 <div id="fb-root"></div>
 <script src="http://connect.facebook.net/en_US/all.js"></script>
 <script>
   FB.init({
     appId  : 'xxx',
     status : true, // check login status
     cookie : true, // enable cookies to allow the server to access the session
     xfbml  : true  // parse XFBML
   });
 </script>
    <script>

        function logout(){
            FB.getLoginStatus(handleFBSessionResponse);
            location.href = '/user_sessions/new';
        }

        // handle a session response from any of the auth related calls
        function handleFBSessionResponse(response) {
            /*
            //Check the facebook login status
            alert("handleFBSessionResponse(), "
             + "\nresponse.status="+response.status
             +" \nresponse.session="+response.session
             +" \nresponse.perms="+response.perms);
            */

            //if we do have a non-null response.session, call FB.logout(),
            //the JS method will log the user out
            //of Facebook and remove any authorization cookies
            FB.logout(handleFBSessionResponse);
        }


        </script>
        <a href="javascript:logout();">Logout</a >

我用这个工作

<a href="http://m.facebook.com/logout.php?confirm=1&next=http://10.1.0.90:8080/registrationForm" >Sign Out</a> 

我想你需要发布更多的代码。您不会将FB传递给注销方法,也不会在注销方法中定义它。这是一个全局变量吗?抱歉..这是我html中该页面的全部der,而不是说用户已登录的文本..我应该如何定义FB?抱歉,我不知道..我对编程很陌生..您正在调用方法FB.GetLoginStatuarg。这意味着FB必须引用具有这种方法的对象。除非您只是在动态地发明方法名称,否则应该在某个地方定义此方法及其对象。getLoginStatus函数在哪里定义?我已经编辑了上面的代码。。我已经添加了一个js文件,我想它包含了所有的FB方法。但是我不确定。你现在能澄清我的疑问吗?我该怎么做才能让它从这里开始工作。