I'm trying to do a ajax request by clicking a span element.
Here the HTML of the span:
<span class="fake-link do-delete" data-id="'. $delid .'">Delete</span>
Here is my jQuery ajax request:
$(".do-delete").click(function() {
var item = $(this).attr("data-id");
$.ajax({
type: "POST",
url: "../assets/includes/ajax/delete-item.php",
data: item,
cache: true,
success: function(data) {
$(".test").append(data);
// alert("De categorie met zijn respectievelijke onderdelen zijn verwijdert.");
}
});
});
Here is my current PHP, to catch the data send by ajax:
if (isset($_POST['item'])) {
$id = $_POST['item'];
echo 'test';
}
But the test isn't coming through, so the item isn't posted...
What am I doing wrong?