Forum Moderators: open
<div id="main_content">
<div>
<form method="post" action="delete.php">
<table>...</table>
<input type="hidden" name="rowId" value="42">
<input type="submit" class="deleteBtn" value="Delete">
</form>
</div>
...
</div>
$('form').submit(function(event) {
// stop the form from submitting normally
event.preventDefault();
// get some values relating to this form/section
var $form = $(this),
url = $form.attr('action'),
rowId = $form.find('input[name="rowId"]').val(),
$nodeToDeleteOnSuccess = $form.parent();
// send the data using post and delete the container on success
$.post( url, {rowId: rowId}, function(data){
if (data === "success") {
$nodeToDeleteOnSuccess.remove();
}
}, "text" );
return false;
});