Refresh the Disqus comment count

Utilizing AJAX, I am fetching articles. To display their comment counts, I utilize the following code:

DISQUSWIDGETS.getCount();

Initially, this method works fine. However, upon loading additional articles and re-calling the function, it fails to exhibit the comment counts for the new articles. There is also no error message displayed. Any suggestions on how to address this issue using Javascript?

Answer №1

This may seem like a workaround, but here's a solution that has been effective:

// Reset disquswidgets to trigger a refresh even on ajax reload
window.DISQUSWIDGETS = undefined;
$.getScript("http://" + disqus_shortname + ".disqus.com/count.js");

By tricking Disqus into thinking the type is undefined, it will re-execute the same code just like the first time it ran.

Answer №2

It is recommended to implement the following code:

DISQUSWIDGETS.getCount({reset: true});

To learn more details, you can visit this link.

Answer №3

For the past few months, my console has been showing this persistent error click here to see the console error

The solution is simple: do not execute the getCount function if the DISQUSWIDGETS variable is undefined.

// First, call the count js
<script async='async' id='dsq-count-scr' src='//yourwebsite.disqus.com/count.js' type='text/javascript'/>

<script type='text/javascript'>
// Next, safely reload disqus comment count with this solution 
if(typeof DISQUSWIDGETS != "undefined") {                                                                                                                    
    DISQUSWIDGETS.getCount({ reset: true });
}
</script>

Answer №4

I have encountered the same issue and was able to find helpful resources that provided a solution.

For more information, you can visit this link. It worked for me.

 window.DISQUSWIDGETS.getCount({ reset: true });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transfer the values of specific keys in an array to a separate array based on the values of another key within the same object that satisfy a particular condition

I am seeking a refined solution to create a function that retrieves the names of legal drivers from a given array of people: function getNamesOfLegalDrivers(people) { } const driverArray = [ { name: 'John', age: 14 }, { name: 'Joey&apos ...

The use of DIV tags allows the element to be displayed in an inline

In my project, I decided to add three div tags. The first two are positioned next to each other with the third div tag placed below them. However, when I tried to insert a slideshow into the first div tag, all of the div tags ended up displaying as "block" ...

Help! My JavaScript Regex is causing a Maximum call stack size exceeded error

I have a lengthy paragraph that requires word boundary comparisons in order to replace matches with the desired value. The desired values will appear in various different patterns, which is why I must create numerous lines of new RegExp to systematically ...

Is there a feature similar to Google/YouTube Insight called "Interactive PNGs"?

Recently, I have been exploring the YouTube Insight feature and I am intrigued by how their chart PNGs are generated. When you view the statistics for a video, the information is presented in interactive PNG images. These images seem to be entirely compos ...

Switching from an angular variable to a PHP variable

Having trouble getting this to work. Can anyone assist me? I want to display detailed user information after clicking on a link, but I'm unsure how to send the information to a PHP file via a link. The link to the detailed user information looks like ...

What is the best way to invoke the update() and ScrollTop() methods in Angular for ngx-perfect-scrollbar?

Currently, I am utilizing the "ngx-perfect-scrollbar": "^5.3.5" library in my project. I have implemented a feature to toggle between "See More" and "See Less", however, when these actions are triggered, the Perfect Scrollbar does not update itself prope ...

Angular allows for displaying objects within other objects using interpolation

Below is the object stored in EntryList variable within my component: { "id": 0, "startAddress": { "id": 6, "addressString": "addressString" }, "endAddress": { ...

Differences between updating partial pages in asp.net MVC and asp.net WebForms (aspx) are worth exploring

Question: I have been experimenting with asp.net mvc and using jquery ajax [http get] to fetch partial mvc views for partial page updates. Is this considered a valid approach for achieving partial page updates? Currently, I am working on an asp.net aspx ...

Looking to receive child events within a Vue 3 setup()?

Looking to convert the code below to use Vue 3 composition API. I am trying to listen for an event from a child component in a parent component that utilizes the render function. In Vue 3, $on has been removed and I'm unsure of how to replace it in t ...

Clickable Angular Material card

I am looking to make a mat-card component clickable by adding a routerlink. Here is my current component structure: <mat-card class="card" > <mat-card-content> <mat-card-title> {{title}}</mat-card-title> &l ...

Generate a visually dynamic representation of a live website page

I'm curious if it's possible to create a login page similar to the one shown in this image, using HTML, CSS, and Javascript. Instead of a traditional background image, I want the background to display the actual layout of another website, such a ...

Toggle between resizing a set of boxes and fading in/out their images

I have a series of clickable boxes that I want to expand and hide the image when clicked. Additionally, I need to be able to close any previously opened box by returning it to its original height and width while fading back in its image content. The .info ...

Enable the use of multiple decimal separators in a ReactJS application

I am currently developing a small project that involves using a POST request, which requires multiple fields with 2 float values. My backend system expects the decimal separator to be a ".", but my target audience is primarily French and they ar ...

"Combining background images with javascript can result in displaying visual elements

Hello! I am in need of assistance with a CSS + Javascript fog effect that I have developed. It is functioning properly on Firefox, Opera, and Chrome but encountering issues on IE and Edge browsers. The effect involves moving two background images within a ...

Making an "associated" route the active route within Aurelia

In my Aurelia application, I have implemented two routes: a list route called Work and a detail route called WorkDetail. Currently, only the list route is visible in the navigation menu: Home | *Work* | Contact | . . . When users navigate to the W ...

Node scripts and node bins are causing errors in Vue.js when running npm

While attempting to run my Vue project with the command npm run serve I encountered an error message that read: [email protected] serve /home/numan/Desktop/vue-getting-started/07-accessing-data/begin/vue-heroes vue-cli-service serve sh: 1: vue- ...

Error occurred while trying to access a file within the server using $_GET method

Struggling to access a URL within my folder, but encountering an error. I have attempted using file_get_contents without success. Warning: include(/home/vol2_3/*****/*****/htdocs/new/td.php?r=8&ids=309834): failed to open stream: No such file or direct ...

Issue with updating Three.js Mesh position

I have been working on mapping lat/long data to a sphere. I am successfully generating vectors with different positions and setting the cube mesh position accordingly. However, when I merge and display the cubes, it seems like there is only one cube show ...

Generating a single JSON record in React Native

Need help displaying a single JSON record from an API request on the screen. const [user, setUser] = useState(); const getUserData = async () => { // {headers: {Authorization: "Basic " + base64.encode(username + ":" + passwor ...

Is it possible for me to initiate an AJAX request to a particular function in a PHP script from a JavaScript file?

I have a JavaScript function that retrieves the latitude and longitude of the user and saves it in an array for future use. My goal is to compare the user's location with multiple other locations stored in a database. I am attempting to achieve this b ...