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

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. You will replace the console.log line with your code.


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

// To go further if you want to wait until all ajax code are executed on the page you can use the code snippet below :
       jQuery(".woocommerce-shipping-methods li label").text(function () { 
             return jQuery(this).text().replace("Table Rate: ", "Taux: "); 
       }); //alert("all ajax executed"); 


Leave a Comment

Your email address will not be published.

Scroll to Top

Choose your language