AddThis button will not work inside AJAX, but will work normally

后端 未结 8 718
温柔的废话
温柔的废话 2021-02-04 17:47

Basically, this is what I\'m doing. User visits site, loads \"index.html\" Within index.html, it automatically loads, through AJAX, \"details.html\" into a DIV. I put an ADDTHIS

相关标签:
8条回答
  • 2021-02-04 18:16

    Ran in the same problem and this solved it for me in all major browsers (IE6+, FF, Safari in MAC/XP):

    http://joecurlee.com/2010/01/21/how-to-use-addthis-with-ajax-and-overflowauto/comment-page-1/#comment-24

    0 讨论(0)
  • 2021-02-04 18:16

    I had the same problem. Fixed it with the following code. I hope that fixes it for you too.

    Original Method:

        var script = 'http://s7.addthis.com/js/300/addthis_widget.js?domready=1';
        if (window.addthis){
            window.addthis = null;
        }
        $.getScript( script );
    

    New Method:

    <script>
    var script = 'http://s7.addthis.com/js/250/addthis_widget.js#domready=1';
    if (window.addthis) {
        window.addthis = null;
        window._adr = null;
        window._atc = null;
        window._atd = null;
        window._ate = null;
        window._atr = null;
        window._atw = null;
    }
    $.getScript(script);
    </script>
    

    In AJAX REQUEST you can use like this:-

    $.ajax({
        url:Url,
        type: 'POST',
        cache: false,
        success: function(res){
            var script = 'http://s7.addthis.com/js/250/addthis_widget.js#domready=1';
            if (window.addthis) {
                window.addthis = null;
                window._adr = null;
                window._atc = null;
                window._atd = null;
                window._ate = null;
                window._atr = null;
                window._atw = null;
            }
            $.getScript(script);
            // your custom code
        }
    });
    
    0 讨论(0)
提交回复
热议问题