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