How to execute jQuery code whenever there is an AJAX call on your website?

Run your jQuery logic after every WordPress or WooCommerce AJAX request so dynamic values don't reset when a button fires another call. Full snippet inside.

Problem: You changed the value of an element using jQuery, however that value resets when you click on a button that updates the data using AJAX.

Here is a quick fix that will make your jQuery code execute on every AJAX call. Replace the console.log line with your code.

jQuery(document).ajaxComplete(function () {
  console.log("Triggered ajaxComplete handler.");
});

// To go further: wait until all AJAX code is executed on the page
jQuery(document).ajaxStop(function () {
  jQuery(".woocommerce-shipping-methods li label").text(function () {
    return jQuery(this).text().replace("Table Rate: ", "Taux: ");
  });
  // alert("all ajax executed");
});