Это мой AJAX
Код: Выделить всё
jQuery(document).ready(function($) {
$('.add-to-cart-btn').on('click', function(e) {
e.preventDefault();
var productId = $(this).data('product-id');
console.log(productId);
// AJAX request
$.ajax({
type: 'GET',
url: '', // AJAX handler URL
data: {
product_id: productId,
action: 'add_product_to_cart'
},
success: function(response) {
// Refresh the cart page
window.location.href = response.cart_url;
}
});
});
});
Код: Выделить всё
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/783 ... using-ajax