Friday 18 March 2016

Facebook SDK does not loading all.js

Facebook SDK doesn't loading and its getting failed


Facebook SDK is NOT Loading properly OR Facebook Login is not working in Few system, Might cause following reasons.
  1. Are you including JS with http OR https like below:
    If Yes, remove the "http:" OR "https://"
  2. Browser plugin is prevent to load the facebook js
  3. Blocking by Firewalls OR Antivirus
  4. Make sure you put that snippet in the <body></body> and not <head></head>
  5. facebook APPLICATION id  is in-correct.

Not Yet Fixed, Then below Code.

    function statusChangeCallback(response) {
        if (response.status === 'connected') {
            console.log('You are login successfuly');
        } else if (response.status === 'not_authorized') {
        } else {

    // This function is called when someone finishes with the Login
    // Button.  See the onlogin handler attached to it in the sample
    // code below.
    function checkLoginState() {
        FB.getLoginStatus(function(response) {

    window.fbAsyncInit = function() {
            appId: 'FACEBOOK_APP_ID',
            cookie: true, // enable cookies to allow the server to access 
            // the session
            xfbml: true, // parse social plugins on this page
            version: 'v2.2' // use version 2.2

        FB.getLoginStatus(function(response) {

        FB.login(function(response) {
            if (response.authResponse) {
                console.log('Welcome!  Fetching your information.... ');
                FB.api('/me', function(response) {
                    console.log(response);//Here you have login details
                    document.getElementById('loginId').style.display = 'none';
                    document.getElementById('alreadyLogin').style.display = 'block';

            } else {
                document.getElementById('loginId').style.display = 'block';
                document.getElementById('alreadyLogin').style.display = 'none';


    // Load the SDK asynchronously
    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id))
        js = d.createElement(s); = id;
        js.src = "//";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
<input id="loginId" onclick="checkLoginState()" style="display: none;" type="button" value="Click To Login in Facebook" />
<input id="alreadyLogin" style="display: none;" type="button" value="Already Login in Facebook" />