Facebook SDK doesn't load…all.js GET failing

為{幸葍}努か 提交于 2019-12-04 02:55:56

I was using ghostery in chrome and didn't notice it blocked 'facebook connect'. I bet you have a similiar problem. Just happened to me.

Eugene
  1. Make sure you're running this code in the context of a web server (your browser URL starts with http: or https: protocol), and not from a local file (should not start with file:).

  2. Make sure you put that snippet in the <body> and not <head>.

Avast Online Security a browser Extension/Addon depending on the browser version you use, has just released a new version (2014) that blocks Social scripts from running...basically they have targetted the google+, facebook, twitter CDN scripts and blocked them...and its ON by default... The funny thing is the options says it stops people tracking you but it complete ignores the google analytics script. LOL avast...nice try...

Facebook has certainly changed that sample code. I orignally thought it was because js.src started with // but the JS SDK may be automatically appending the http: or https:

My code goes something like:

 <script type="text/javascript">
    var fbAppId = 'xxxxxxxxxx'

    window.fbAsyncInit = function () {
        FB.init({ appId: fbAppId, status: true, cookie: true,
            xfbml: true
        });
    };
    (function () {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
      '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    } ());   
</script>

notice how mine has document.location.protocol before the url.

Try it that was and see if that helps. My code is obviously an older but still working version.

Check for any antivirus plugin/extension. I have Avast which has a browser plugin/extension. I changed the social networking settings and it worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!