I'm using the same code provided in the here
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
console.log('got here');
FB.init({
appId : '197112467099018', // App ID
channelUrl : '//WWW.MYDOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
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.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
Chrome's console is telling me the script failed to load (GET failed) with 2 errors which are labeled (anonymous function)
The lines it points to as the errors are:
ref.parentNode.insertBefore(js, ref);
}(document));
Can anyone help me figure out whats wrong with these lines?
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.
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.