-2
I’m just trying to increase the notification of an item. I want every time I add a new item to my cart, I have to see the cart notification increase number. in the javascript console I see that it is working well but on my screen nothing changes. someone can help me to see where this the problem please?
This is the HTML part. I’m using id="show_result" to show what rolls in the back-end with ajax.
<li class="ml-4"><a href="#login" id="total_cart" class=" text-danger " data-toggle="modal" data-target="#SignUp"><span class="fa fa-shopping-cart fa-2x"></span><span id="show_result"></span></a></li>
This is the javascript part with ajax:
setInterval(function()
{
$.ajax({
type: "get",
url: "API/READ/count_panier.php",
success:function(data)
{
$('#show_result').html(data);
//console.log the response
console.log(data);
}
});
}, 1000); //10000 milliseconds = 10 seconds
// MAKING REGISTRATION
And here’s the page I call to tell you if there’s any data that’s been added to the cart.PAGE: count_panier.php
$count = $conn->prepare("SELECT *FROM panier");
$count->execute();
$counter = $count->rowcount();
echo '<span class="badge badge-pill badge-danger">'.$counter.'</span>';
As you say that in the console appears correctly, the problem is in your HTML and/or css and in this case there is not enough data in the question to verify the problem. I would also say that it doesn’t make much sense for your "api" to return HTML. You should change the return to a JSON, for example.
– tvdias