Reputation: 1486
I've set up a custom Facebook share button for a website. When I click that button in Firefox it serves me a nice share dialog (popup) with all var's I've defined. Posts to my wall in Facebook, all nice! But the same code fails in Chrome, Safari, IE. It throws me an error in the popup: "An error occurred. Please try again later."
The javascript I'm using (alongside OG meta-tags in the head of course): The website where I use this script: http://www.henkeningrid.org (the Like button gets activated when a quote is clicked)
el.find('a.facebook-feed').click(function() {
var quote = $(this).parents().find('h1').html();
var url = $(this).parents('article').attr('data-url');
var publish = {
method: 'feed',
message: '',
name: 'Henk en Ingrid',
caption: '“'+quote+'”',
description: ('De wereld volgens Henk en Ingrid.'),
link: 'http://www.henkeningrid.org/nl/quote/'+url,
picture: 'http://www.henkeningrid.org/site/gfx/fb_preview.png',
actions: [{name: 'Henk en Ingrid', link: 'http://www.henkeningrid.org/'}],
user_message_prompt: ''
};
FB.ui(publish);
//return false;
});
Upvotes: 1
Views: 2893
Reputation: 1606
I had the same problem, and your "aync loading"-answer pointed me in the right direction. If you're using jQuery, my suggestion is to use the callback as described here: https://developers.facebook.com/docs/javascript/howto/jquery/ Worked for me!
$(document).ready(function() {
$.ajaxSetup({ cache: true });
$.getScript('//connect.facebook.net/en_UK/all.js', function(){
FB.init({
appId: '<?=FACEBOOK_APP_ID?>'
});
alert('FB loaded');
yourFunction();
});
});
Upvotes: 0
Reputation: 28
We were having this problem with the new version of the JavaScript SDK as well - it's odd that it only happens on Chrome but the solution was, indeed, to remove the synchronous version of the SDK as well. We kept the asynchronous code and it fixed the issue we were seeing across all browsers.
<div id="fb-root"></div>
<script>
(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/all.js#xfbml=1&appId=XXXXXX";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
</script>
Upvotes: 1
Reputation: 41
probably because you inserted the sdk twice; in the header and in the body using the async method. i had the same problem. removed the line in the header and then it worked.
Upvotes: 1