0

I am following a tutorial to implement social share count buttons like the user in this post. I've sent the correct http request for get_social_counts.php, but it's still not working.

The buttons load correctly and I can share the page, but the count is not displayed. I have used the exact same HTML as in the tutorial. It also doesn't work on a remote server.

Here is the JavaScript function:

function get_social_counts() {
    var thisUrl = window.location.protocol + "//" + window.location.host + window.location.pathname;
    $.ajax({
        type: "GET",
        url: 'http://localhost:1234/site/php/get_social_counts.php?thisurl='+thisUrl,
        dataType: "json",
        success: function (data){
            $('a.post-share.twitter span').html(data.twitter);
            $('a.post-share.facebook span').html(data.facebook);
            $('a.post-share.gplus span').html(data.gplus);
            $('a.post-share.stumble span').html(data.stumble);
        }
    });
}
Community
  • 1
  • 1
traderjosh
  • 321
  • 5
  • 16
  • What is the response from `http://localhost:1234/site/php/get_social_counts.php?thisurl='+thisUrl`? Have you checked the network console to ensure the request is being made successfully? – ʰᵈˑ Dec 08 '16 at 16:13
  • There are no error messages in the developer console, but when i remove http://, then I get an error, so I think the response is OK. – traderjosh Dec 08 '16 at 16:17

0 Answers0