I’m having troubles with posting the value of a data attrubute e.g. data-fruit=”orange” I basically want to do it with jQuery ajax and I imagine it would look something like this
var fruit = $(".fruit img").attr("data-skin");
$('.box').click(function() {
$.ajax({
url: 'fruits.php',
type: 'post',
data: fruit
});
});
Should the php $_POST look like this:
$friutType = $_POST['data-friut']
Cheers
You need to send key/value pairs to
data, not just a value.Then in PHP: