I have a form with 2 buttons, Confirm & Delete. I am posting a hidden input element ID. When Confirm is clicked, an action will be taken by using the element ID. If Delete is clicked, an entry in DB with the element ID is deleted. Now, the issue is when I do a print_r($_POST); exit();, it gives me the input element ID correctly. But it does NOT tell me which button was clicked. Is there a way to find out which button was exactly clicked in a single form? Both the buttons need to exist in the same form.
Here’s my code that I tried:
jQuery
var dataString = $('#form_confirm_delete').serialize();
$.ajax({
type: "POST",
url: "ajaxpage.php",
data: dataString,
dataType: 'json',
cache: false,
success: (function(response)
{
alert('Yes');
})
});
PHP page (ajaxpage.php):
<?php print_r($_POST); exit(); ?>
you can use something like this
and in server side you can get that variable
or you can use post variable