Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5995409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:57:20+00:00 2026-05-22T23:57:20+00:00

I have been puzzling with this for quite a while and can’t get it

  • 0

I have been puzzling with this for quite a while and can’t get it to work. Here is the situation. I want a SOCIAL MEDIA bar to ONLY appear if people click some DIV. It should not be loaded unless people click the div. For Social Media I have ADD THIS, and the GOOGLE+1 icon. But I can not get them to load by such an external call. Here is the code so far:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>Test</title> 
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=ISO-8859-1" /> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
<script type="text/javascript"> 
$(function(){
    $("#socialmedia").live('click',function(){
            $("#loadhere").load('html-part.html');
            $.getScript('js-part.js');
    });

});
</script> 
</head> 
<body> 


<div id="socialmedia"> 
 Show the Social Media
</div> 

<div id="loadhere"> 

</div> 


</body> 
</html> 

In the HTML part I have the HTML info that needs to be loaded:

html-part.html:

<!-- AddThis Button BEGIN --> 
    <div class="addthis_toolbox addthis_default_style "> 
        <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> 
        <a class="addthis_button_tweet"></a> 
        <a class="addthis_counter addthis_pill_style"></a> 
    </div> 

    <!-- AddThis Button END --> 
    <g:plusone size="medium" id="gg"></g:plusone> 
</div> 

For the JS part I am struggling. Here is what needs to be loaded:

<script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> 
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ID"></script> 
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> 

I have tried to call them one by one:

$.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=ID');
$.getScript('https://apis.google.com/js/plusone.js');

But I guess this is a crossdomain problem…?

If I use PHP to obtain the content, and load a local PHP file, it still does not work. Before spending one more day on this… is this possible to achieve?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:57:21+00:00Added an answer on May 22, 2026 at 11:57 pm

    The problem here is that addthis code fires on dom ready event. When you load it with jQuery the dom has already been loaded so the code is not executed. The fix is to use addthis.init() method to force the code execution after you load the code. There is no cross domain problem or anything.

    Note that according to addthis documentation it should be possible by just passing a get variable through the widget url like this http://s7.addthis.com/js/250/addthis_widget.js#pubid=[PROFILE ID]&domready=1 but it didn’t work for me.

    I would also recommend you store the html in a string variable, that way you don’t have to do unnecesary requests for a little static html.

    See working demo here: http://jsfiddle.net/z7zrK/3/

    $("#socialmedia").click(function(){
        var add_this_html =
        '<div class="addthis_toolbox addthis_default_style ">'+
        '<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>'+
        '<a class="addthis_button_tweet"></a>'+        
        '<a class="addthis_counter addthis_pill_style">'+
        '</a>'+ 
        '</div>'+
        '<g:plusone size="medium" id="gg"></g:plusone>';
    
        $("#loadhere").html(add_this_html);
        $.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=xxx',
        function(){
            addthis.init(); //callback function for script loading
        });  
    
      $.getScript('https://apis.google.com/js/plusone.js');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been using it for a while with CodeIgniter and I can't remember if
I have been developing in ASP.NET MVC for a short while. Up to this
I ran into a very disturbing issue that's been puzzling me for a while
Have been searching for this, I need to have a conditional statement in my
I have been trying to register 3 hotkeys. I followed this example (or this
I have been struggling trying to test a super simple EJB project in netbeans.
Have been pulling out my hair trying to find out why my sessions are
Have there been any improvements in debuggers in the past 20 years or so?
I have entity Problem mapped using many-to-many to entity Tag (Problem has a list
No worries! It looks more complex than it actually is! Just get down to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.