Reload the comment count of Disqus

喜夏-厌秋 提交于 2019-12-06 08:22:53

问题


I am loading articles with AJAX. When I want to show their comment counts I use:

DISQUSWIDGETS.getCount();

This works. But when I load more articles and call the function again it does not show the comment counts of the articles. It also does not give any error. Is there a way to solve this problem in Javascript?


回答1:


It might be something of a hack, but this works:

# Undefine disquswidgets to force a refresh also on ajax reload
window.DISQUSWIDGETS = undefined;
$.getScript("http://" + disqus_shortname + ".disqus.com/count.js");

Basically you trick Disqus into believing that the typeof is undefined, which will make it execute the same code again as it does the first time it's run.




回答2:


You should use this:

DISQUSWIDGETS.getCount({reset: true});

For more information, see here



来源:https://stackoverflow.com/questions/21333184/reload-the-comment-count-of-disqus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!