Nidhin S G
Nidhin S G

Reputation: 1695

Facebook Share in Ruby on Rails

In my rails app i have done facebook share like this..

<li class="facebook">
            <a href="javascript: void(0)" onclick="window.open('https://www.facebook.com/dialog/feed?app_id=<%= FACEBOOK_APP_KEY %>&amp;display=popup&amp;description=<%= $fb_share_text %>&amp;name=<%= $fb_share_name %>&amp;picture=<%= request.base_url %>redirect_uri=<%= FB_CALL_BACK_URL %>','sharer','toolbar=0,status=0,width=548,height=325');"></a>
</li>

Can I do the same thing using jquery ajax call. Because i want to do something on the success function like updating some html.. Pls help..

Upvotes: 1

Views: 2874

Answers (2)

Nikhil
Nikhil

Reputation: 3152

This SO answer covers sharing using the Facebook JavaScript API. Should be exactly what you're looking for. It has a callback on success as well.

The link to the Facebook Docs on FB.ui() is here.

Some sample code from the page with the callback:

FB.ui(
  {
    method: 'share',
    href: 'https://developers.facebook.com/docs/',
  },
  function(response) {
    if (response && !response.error_code) {
      alert('Posting completed.');
    } else {
      alert('Error while posting.');
    }
  }
);

Upvotes: 3

Sree
Sree

Reputation: 104

Try to put in a function and make an ajax request.

Upvotes: 0

Related Questions