Monday, August 22, 2011

Addthis and ajax response page

There are lots of post regarding Addthis api usage for AJAX page. But none of the post worked perfectly for me. However i got some idea from all that posts to implement it. Here is my code, made little changes from different post.

var addthisScript = "http://s7.addthis.com/js/250/addthis_widget.js#domready=1";/>

function initAddthis(){
if (window.addthis){
window.addthis.ost = 0;
window.addthis.init();
}
}

When you load page using ajax for example (here i have used jQuery)
$.load('http://example.com/lists',function(){
if(window.addthis != undefined) {
  delete window.addthis;
}
$.getScript( addthisScript , function(){
initAddthis
});
});
Please let me know, does it work for you.

No comments:

Post a Comment