未捕获的ReferenceError:未使用facebook API定义checkLoginState [英] Uncaught ReferenceError: checkLoginState is not defined using facebook API

查看:151
本文介绍了未捕获的ReferenceError:未使用facebook API定义checkLoginState的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试修复此代码,但我在控制台上遇到此错误:

I keep trying to fix this code but I am stuck with this error on my console:


未捕获的ReferenceError:未定义checkLoginState 。

Uncaught ReferenceError: checkLoginState is not defined.

我只是按照本指南。这是我的函数代码,当我调用它时:

I simply followed this guide. Here is my code for this function and when I call it:

function checkLoginState() {
  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });
}


<fb:login-button data-max-rows="1" data-size="large" data-show-faces="false" data-auto-logout-link="true" onlogin="checkLoginState();" scope="public_profile, pages_show_list"></fb:login-button>


推荐答案

这:

function checkLoginState() {
  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });
}

应该在< script> block

<script>
    function checkLoginState() {
      FB.getLoginStatus(function(response) {
        statusChangeCallback(response);
      });
    }

    // Load the SDK asynchronously
    (function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/sdk.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

这篇关于未捕获的ReferenceError:未使用facebook API定义checkLoginState的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆