I have a cartItem variable which includes title, price etc. I make an AJAX request when I click the 'add to cart' button but it returns [object Object] output instead of its title and price.
let cartTitle = $('.card-title', addCartItem);
let cartDescription = $('.card-description', addCartItem);
let cartPrice = $('.price', addCartItem);
var id = this.dataset.productId
$.ajax({
type: 'GET',
url: ('/getData'),
data: {
id: id
},
success: function(data) {
cartTitle.text(data.title)
cartPrice.text(data.price)
cartDescription.text(data.description)
$('tbody').prepend(cartItem)
}
})