How to continuously update cart price without page refresh?

Howdy, I added some code to my cart-notification.liquid file that displays the price when someone adds something to their cart, the only problem is the price doesn’t update unless the page is refreshed, I was given a snippet of JavaScript code using ajax to fix this but either I am not implementing it right or It doesn’t work. Please help, I really need to figure this out. Below is my code.

{% comment %}
    Renders cart notification

    Accepts:
    - color_scheme: {String} sets the color scheme of the notification (optional)

    Usage:
    {% render 'cart-notification' %}
{% endcomment %}
                

{% style %}
  .cart-notification {
     display: none;
  }
{% endstyle %}

The code you provided seems to be correct for updating the cart price in the cart notification. However, there might be a couple of things you can check to ensure it works properly:

  1. Make sure the ShopifyBuy library is loaded: The Shopify.cart.getCart method is part of the ShopifyBuy library, which needs to be loaded on your website. Ensure that the library is properly included in your theme’s code. You can check if it’s loaded by looking for a script tag that includes cdn.shopify.com/shopifycloud/shopify-buy.

  2. Verify the element IDs: Double-check that the element ID cart-price exists in your theme’s HTML code. Ensure that the script can find the element and update its contents correctly.