Answer the question
In order to leave comments, you need to log in
How to refresh part of a page?
There is a certain online store, it has products that can be added to the cart. So I screwed the add ajax button to the button and when you click the data, via post, they fly to the server, where it writes them to the basket session. But I want the cart to be updated without reloading the page. I know that json should be used here. But how exactly to implement - I do not understand. Even figure out the sequence of actions.
Answer the question
In order to leave comments, you need to log in
The easiest way is to issue a cart code on some request and simply replace the old cart with a new one.
$.get('/get-cart.html', function(data){
$('.my-cart').replaceWith(data);
});
If you don't want to get too deep, then
$('#cart-block').load(location.href + ' #cart-block', function() { $(this).children().eq(0).unwrap() });
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question