Javascript function doesn't load on Ajax refresh

I use this script for converting English numbers to Persian numbers:


window.onload = function persianModule(){
      var els = document.querySelectorAll('.woocommerce-Price-amount, .amount ');
      els.forEach(function(item) {
        item.textContent = persianJs(item.textContent).englishNumber().toString();
      });
    };

When page reloads with an Ajax function, above script doesn’t work but after page refresh through browser it works very nice.
How can I force above script do the function even after an Ajax reload?

How are you calling the Ajax function?

I don’t know honestly, it is just WooCommerce checkout page, even I don’t know why it is using Ajax reload after landing checkout page.

Well, you’ll need to find out where it is called and then attach some kind of success callback to call your persianJs function.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.