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?
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?
Share Improve this question edited Jan 24, 2014 at 12:52 user170442 asked Jan 24, 2014 at 12:49 KlaasvaakKlaasvaak 5,64416 gold badges48 silver badges68 bronze badges4 Answers
Reset to default 19It 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.
You should use this:
DISQUSWIDGETS.getCount({reset: true});
For more information, see here
This was the error that annoys my console for a couple of months console error here for reference
Basically, you shouldn't run the getCount function whenever the DISQUSWIDGETS variable is undefined.
// call the count js first
<script async='async' id='dsq-count-scr' src='//yourwebsite.disqus.com/count.js' type='text/javascript'/>
<script type='text/javascript'>
// then the solution to reload disqus comment count safely
if(typeof DISQUSWIDGETS != "undefined") {
DISQUSWIDGETS.getCount({ reset: true });
}
</script>
I have also faced this issue and for the solution I found some good resources and solution from them.
For more enter link description here.This one works for me.
window.DISQUSWIDGETS.getCount({ reset: true });