I got an <img> which user should be able to click (to delete a post on a wall for example). Every image got the "imageid" which matches the ID of the article itself. Now I want to pass this "imageid" via javascript/jQuery/whatever to my delete.php file where I send that ID to my Oracle database to know what article to delete.
IMGs looks like:
<img alt="Delete Article" src="include/images/delete.png" imageID="21" title="Delete Article">
And the javascript:
$(document).ready(function erase() {
$("img[title='Delete Article']").click(function() {
if (confirm("Are you sure?")) {
var image = $(this).data('imageID');
$.ajax({
type: "POST",
url: 'include/site/delete.php',
data: 'imageID=' + image,
});
}
});
});
I only found the way to create a hidden form tag and to send it that way, but I want to do it (if possible) in another way :)
Thanks in advance
Found solution!
$(document).ready(function () {
$("img[title='Delete Article']").click(function() {
if (confirm("Are you sure?")) {
var getimageID = $(this).attr('imageID');
$.post("include/site/delete.php", {
catchedID : "ID ist " + getimageID
});
}
});
});
data-*attribute instead.data-imageidshould replaceimageid.