Share buttons are not updating properly on dynamically refreshed pages

I'm currently using ajax to fetch a new page, but I'm encountering an issue where only the share buttons are being displayed without the share count.

$("body a").click(function(e) {
  $.ajax({
    url: ajax_url,
    type: "GET",
    dataType: "xml"
  }).done(function(data, textStatus, jqXHR) {
    if (typeof(history.pushState) != "undefined") {
      var obj = {
        Title: title,
        Url: url
      };
      history.pushState(obj, obj.Title, obj.Url);
    } else {
      alert("The browser does not support HTML5.");
    }

    var $divToFind = $($.parseHTML(jqXHR.responseText)).filter("#radio-main-wrapper");
    $('#radio-main-wrapper').html($($divToFind).html());
    $.getScript("http://w.sharethis.com/button/buttons.js");
    stButtons.locateElements();
  }).fail(function(jqXHR, textStatus, errorThrown) {

  });
});

Answer №1

If you're experiencing difficulties with ajax, consider utilizing the easyshare plugin available here:

https://github.com/kyco/jquery.kyco.easyshare

This solution is user-friendly and can effectively address your ajax issue.

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

Utilize TinyMCE in your WordPress plugin

How can I integrate TinyMCE into my WordPress plugin? I have a textarea in the backend script that I would like to convert into a TinyMCE WYSIWYG editable field. Is there a method to achieve this? The following code snippet is not yielding the desired re ...

Creating an intelligent autocomplete feature in JavaScript that recognizes the . character as a wildcard for matching any character

I found this code and would like to enhance its functionality. For instance, when I search for ".an.d", I want the code to display all words that have an "a" at the second position, "n" at the third position, any character at the fourth position, and "d" ...

Retrieve the date information from the <td> element, if it exists

There are numerous rows in the table. The table cell labeled "dates" may contain either a specific date or the word "Permanent". If there is a date present and it happens to be greater than today's date, it needs to be highlighted in red. I attempted ...

What is the best way to insert an <image> tag into the SVG DOM?

Currently, I am facing an issue with adding a background image to the generated SVG DOM in my web page. The user interacts by drawing an SVG doodle on top of a jpg image using Raphael. After the user is done with their drawing, I want to enable them to sa ...

Creating unique identifiers/primary keys for resources in react-admin: A step-by-step guide

I am working on a nextJS project that utilizes redux for state management and an admin panel called react admin. In my project, I decided to use _id instead of id as the keys. To achieve this, I followed the instructions provided in this custom identifiers ...

Is there a way for a Vue component to interact with a button or checkbox in order to dynamically update tooltip content and button style using a function?

Is it possible for a Vue component to trigger button clicks or checkbox checks in order to update tooltip text and button color using a function? Despite the presence of a handle() function in the code provided, these changes are not currently taking effec ...

I am having trouble resizing events in the month view of FullCalendar

After making an AJAX call to the server, I receive an event list. The strange thing is that even though I have set the "editable" option to "true", it only seems to work in agendaDay and agendaWeek views, not in month view. Here's the code snippet: $ ...

Angular Display of Scrolling Feature not Functioning Properly

After clicking on show5 and then goto5, everything functions as expected. However, when clicking on showngo5, it does not work as anticipated, despite the fact that the same methods are being called. What is causing showngo5 to not work in this plunker h ...

What is the best location to store reusable backend scripts in a Node.js project?

In my Nodejs project, I am working on creating a JavaScript file that is not a middleware. This file will contain a function that takes a value as input and produces an output using module.exports. I am currently deciding on the best location to store this ...

Challenges with implementing JSONP in jQuery autocomplete feature

I recently had a learning experience where I encountered an issue with autocomplete functionality. No matter what I tried, I couldn't get the dropdown to show the airline names after typing in DELTA in the #air input field and making the request. Whil ...

Display issue with ThreeJS cube

Currently, I'm delving into the world of ThreeJS and decided to incorporate the library into my existing NextJS project. My goal was simple - to display a cube on the front page. However, despite my best efforts, nothing seems to be appearing on the s ...

Is it possible for a React blog to be included in search engine results?

As I work on building my blog using React, Node.js, Express, Sequelize, and other technologies, a question has arisen in my mind: Will search engines index my articles, or will only the homepage of my site be noticed? For instance, if I have an article ti ...

Exploring JavaScript's Modules, Enclosures, and Scoping

Utilizing a closure pattern to compartmentalize my code: (function(root) { // MODULE CODE HERE if (typeof module !== 'undefined' && module.exports) { // CommonJS /* var dependencies = require(...) */ module.exports = myModu ...

Assign an identifier to the bootbox textarea

To initiate the bootbox with a textarea, use the following code snippet: bootbox.prompt({ title: "This is the title", inputType: 'textarea', placeholder: 'Feedback', callback: function (result) { console.log(result); } }); You ...

Display the HTML content retrieved from the SailsJS Controller

Exploring the world of SailsJS, I am on a mission to save HTML content in a database, retrieve it, and display it as rendered HTML. To achieve this goal, I have set up a sails model and a controller. This is what my model looks like: attributes: { ht ...

Selenium struggles to interact with Javascript:void(0) links

Currently attempting to web scrape a website using Selenium, encountering an anchor element that needs to be clicked with an href value of: javascript:void(0) If interested in viewing the website firsthand, the objective is to select the "I accept" button ...

Having trouble targeting a div with jQuery

Is it possible to target a specific div within an unordered list and list items? I'm having trouble with it. Here is the HTML code: <ul class="grid"> <div id='categoria' cat='web'></div> <li id=' ...

Separate a tab delimited text file and store it into an array using JavaScript

Looking to parse a text file with tab-separated values in JavaScript and add them to an array? Here's how you can achieve this while excluding the header: Id Symbol 1 A 2 B 3 C 4 D 5 E 6 F 7 G This is what I have attempted so far: va ...

The function(result) is triggered when an http.get request is made

Can anyone help me figure out why my function is jumping after completing the request? It seems to be skipping over .then(function(result){ }. I suspect that the issue might be related to the <a> element with an onclick attribute containing an href ...

There was an issue with Sails.js where it was unable to retrieve a recently created user using a date

One issue I encountered with Sails.js was using sails-disk as the database. When querying for a user with specific date parameters, such as: // Assuming the current date is end_date var end_date="2014-06-06T15:59:59.000Z" var start_date="2014-06-02T16:0 ...