微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jquery – Addthis与Ajax无效

我正在使用Ajax加载所有文章,但Addthis功能不正确
$thisChild.load( permlink + ' #thePostStuff',function() {

而在.backup()函数的回调中,我添加了这个代码来引入Addthis共享功能

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

由加载Addthis脚本的ajax请求调用的permlink文件内容中的代码如下所示:

<!-- AddThis Button BEGIN -->
<div class="addthis_toolBox addthis_default_style addthis_32x32_style"
        addthis:url="<?PHP the_permalink(); ?>"
        addthis:title="<?PHP the_title(); ?>"
        addthis:description="<?PHP the_excerpt(); ?>"> 
    <a class="addthis_button_facebook"></a>
    <a class="addthis_button_twitter"></a>
    <a class="addthis_button_preferred_3"></a>
    <a class="addthis_button_compact"></a>
    <a class="addthis_counter addthis_bubble_style"></a>
</div>
<!-- AddThis Button END -->

问题是,addthis没有按预期加载.它在第一次打开文章时工作,但任何其他时间(除非页面被刷新)都无法包含显示文章共享多少次的数字,当我检查元素显示为这样:一个class =“addthis_button_expanded”target =“_ blank”title =“查看更多服务”href =“#”> 1< / a>

编辑:

尝试一个已知的修复:$.getScript(script,function(){addthis.init();});但这并没有解决问题.

编辑2012年8月14日

该网站是http://epicvan.com,我刚刚删除了数字,因为我从来没有想到一个修复,而我正在处理它.该项目几个月前完成,所以我不会测试新的答案.希望他们能帮你,如果遇到同样的问题!干杯

解决方法

我有同样的问题.修正了以下内容.希望你也修复它.

原版的:

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

新:

<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>

原文地址:https://www.jb51.cc/jquery/179870.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐