How to add Product to Cart with Ajax in Shopify

Put the following code in your liquid file:

$(document).on("click", "button#AddToCart", function(){
 
   
                $.ajax({
                type: 'POST',
                url: '/cart/add.js',
                data: {
                  quantity: 1,
                  id: {{ variant.id }}
                },
                dataType: 'json',
                 success: function (data) {
			window.location.href = '/cart'; 
                 }
                 });
     });

Now you can see items data which are added in your cart.add Product to Cart with Ajax in Shopifyadd Product to Cart with Ajax in Shopify