Search code examples
javascriptjquerysquarespace

Links via JQuery Are Working Correctly Resulting in Error or Missing URL


I'm trying to get social share links to work but they result in an error.

For example,clicking LinkedIn button results in the following error:

"We're sorry. Something unexpected happened and your request could not be completed. Please try again." so basically no way to post article. I'm running into similar issues for others and for Facebook, I can't get it work even though the SDK is public.

Here's the page

I've created a code pen

var topButtonsVisible = !0,
  bottomButtonsVisible = !1,
  GooglePlusUrl,
  redditUrl,
  bindInviews = function() {
    $("#myShareButtonsBottom").bind("inview", function(a, b) {
      bottomButtonsVisible = b ? !0 : !1
    });
    $("#myShareButtonsTop").bind("inview", function(a, b) {
      topButtonsVisible = b ? !0 : !1
    })
  },
  setShareEvents = function() {
    $(".myFacebookBtn").click(function() {
      FB.ui({
      ...

Solution

  • It's hard to say for this, but from your codepen, it doesn't work and seems you are missing jQuery. You need to have jQuery on the page for any of this to work.

    I added jQuery to the codepen and it seems to work with that in place, with the exception of FB. FB also requires their own library to be included on the page.

    You can start by adding one of the links from here for jQuery to the page: https://code.jquery.com/

    jQuery link needs to be before your script that runs. That should fix most of your issues.

    You'll have to comment out your FB call from setHackernewCount(); in your document ready, then all the rest should work.

    This page, https://developers.facebook.com/docs/javascript/quickstart should give you what you need (instructions wise) to use the FB.ui javascript API.

    UPDATE: After more investigation I do not see this script even on the page you're trying to use it on. You will need to start there and add the script to the page.