I'm making my first website and I've encountered a problem with AJAX. I have tried and searched a lot of things but I'm missing something, please help me on this one. I have products' count and it works fine, but I need to refresh page everytime when I add new product to cart to see difference, so I need to use AJAX on my php variable. Please help me write AJAX code. I really appreciate it, thanks a lot and have a good day!
PHP Code:
<?php
$cart = new cart();
$products = $cart->getCart();
$sum = 0;
foreach($products as $product){
$sum += $product->count;
}
echo $sum;
?>