Hi I am just learning to work with jquery and ajax.And an tryin gto berform a basic jquery call and retrieve an ok.But it seems I get back nothing.
This is my html:
<a href="#" class="addToCart" id="'.$idProduct.'" name="cart">Add to Cart</a>
This is my jquery code:
$('.addToCart').on('click', function(){
var itemId = $(this).attr("id");
$.ajax({
url: 'cart.php',
type: 'POST',
data: itemId,
dataType:'html',
success: function(result){
alert(result + " ceva ");
},
error : function(data){
alert(data);
}
});
});
And this is my php code:
echo $_POST['cart'];
When I try to run this in the success alert I get back this:

How can make this ajax call to work properly?