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

后端 未结 8 859
温柔的废话
温柔的废话 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

    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:

    
    

    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
        }
    });
    

提交回复
热议问题