How to update the WooCommerce cart Icon to show new products added with JavaScript

Heres a nice article describing how to do this, but a very different approach to yours :
https://aceplugins.com/ajax-add-to-cart-button-on-the-product-page-woocommerce/

Since you know how many items are being added to the cart (1 based on your link) you could just fake some addition and upate the cart icon value

Assuming the cart icon number has an id “cart-icon’ Eg :

 function addToCart(p_id) {
   $.get('?add-to-cart=" + p_id, function() {
      // SO IF YOU ALREADY HAD 3 IN CART IT WILL NOW BE 4
       $("#cart-icon').text( $('#cart-icon').text() + 1);

   });
 }