Deleting row after successful response from Jquery post
Deleting row after successful response from Jquery post
I am noob at Jquery and all that stuff, so please help me a bit :)
This is delete function I am using to delete record from MySQL:
[code]
function DeletePublisher(publisherid) {
jConfirm('Are you sure you want to delete this publisher?', 'Delete publisher', function(r) { if (r)
$.ajax({
type: "POST", //or GET
url: 'includes/publishers/delete-publisher.php?publisherid=' + publisherid,
data: '',
success: function(response){
$.jGrowl('Publisher deleted');
window.location.reload();
}
});
});
}
[/code]
I am displaying table like this:
[code]
...A LOT OF COLUMS...
<?php echo $publisher_unpaid; ?>
Edit
Delete
[/code]
Now all this works OK, but, as you may see, I do a refresh in order to update table, but can't figure out HOW TO DELETE only that particular row (so not to refresh whole page all the time ?)... I just don't know how to implement fnDeleteRow in this case :(
Thanks !
This is delete function I am using to delete record from MySQL:
[code]
function DeletePublisher(publisherid) {
jConfirm('Are you sure you want to delete this publisher?', 'Delete publisher', function(r) { if (r)
$.ajax({
type: "POST", //or GET
url: 'includes/publishers/delete-publisher.php?publisherid=' + publisherid,
data: '',
success: function(response){
$.jGrowl('Publisher deleted');
window.location.reload();
}
});
});
}
[/code]
I am displaying table like this:
[code]
...A LOT OF COLUMS...
<?php echo $publisher_unpaid; ?>
Edit
Delete
[/code]
Now all this works OK, but, as you may see, I do a refresh in order to update table, but can't figure out HOW TO DELETE only that particular row (so not to refresh whole page all the time ?)... I just don't know how to implement fnDeleteRow in this case :(
Thanks !
This discussion has been closed.
Replies
[code]
t.fnDeleteRow( $('#myTable tbody tr:eq(0)')[0] );
[/code]
Allan
Allan
$('#myTable tbody').on( 'click', 'tr', function () {
var tr = this;
$.ajax( {
...
success: function () {
t.fnDeleteRow( tr );
}
} );
} );
[/code]
where `t` is the DataTables instance.
Allan