# Jquery: Delete After Adding to Database

**URL:** <https://forum.kirupa.com/t/jquery-delete-after-adding-to-database/311187>\
**Category:** web dev\
**Created:** [June 29, 2010, 7:29pm UTC](https://forum.kirupa.com/t/jquery-delete-after-adding-to-database/311187 "2010-06-29T19:29:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drummer392](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@drummer392](https://forum.kirupa.com/u/drummer392)\
**Post date:** [June 29, 2010, 7:29pm UTC](https://forum.kirupa.com/t/jquery-delete-after-adding-to-database/311187/1 "2010-06-29T19:29:14Z")

</div>

I have a jquery code that adds data to the database without having the reload which works great. The problem is I want to delete information after I add it. The jquery will let me delete if I refresh the page, but not if I try to delete after I have added to the database. I have tested it to see if there is an id getting through after I add to the database and it is. So I don’t see what the problem is.

Well here is my code for deleting:

```auto
$(function() {
$(".delete_button").click(function() {
var id = $(this).attr("id");
var dataString = 'id='+ id ;
var parent = $(this).parent();

$.ajax({
type: "POST",
url: "delete_element.php",
data: dataString,
cache: false,

success: function()
{
if(id % 2)
{
parent.fadeOut('slow', function() {$(this).remove();});
}
else
{
parent.slideUp('slow', function() {$(this).remove();});
}
}
});

return false;
});
});

```
