Topic: [Share] How To Load AddThis Using AJAX

By "AddThis" above, I mean the world's largest sharing platform on www.addthis.com. If you load it using AJAX, for example, you embed it on a web-page that's loaded using AJAX, it won't show up. You won't see it. There are a few lines of javascript codes you need to add in order to load AddThis using AJAX. And here they are:

var addthis_url = "http://s7.addthis.com/js/250/addthis_widget.js#pubid=your_id";
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(adthis_url)

Just include them on your javascript and you would be able to load AddThis on a page that's loaded using AJAX. In order to make them work, of course you need to include jQuery library on the page.

In short, the above codes will check if there's AddThis script on your page. If there is, then they will reload them by setting some of attributes with null value.

Sources : Kevin HQ - How To Load AddThis Using AJAX

Last edited by kevinhq (2012-12-16 08:07:56)