PDA

View Full Version : Jquery Delete


stevenmw
10-18-2009, 04:05 AM
I know very little about javascript.

I'm using the jquery to delete a row from my database without refreshing the page.

The function works. The javascript deletes the row without any trouble.

I'm using php to echo the contents of a database, and display each item seperately. I'm also echoing the id of the row right above the text that gets deleted.

When I click my 'delete' link the row gets deleted from the database. The text that is being displayed fades away, but the class (css) that is around the text, and the id that is being echoed stays there.

When I refresh the page obviously the css, and id are gone.

Is there a way I can make the function remove everything, or at least hide the deleted items until the page is refreshed.

Below is my code. I'm sure I could just alter one of the classes that are named in the code to change the css when the item is deleted, but I wouldn't know which one to alter.

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

if(confirm("Sure you want to delete this one?"))
{

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

success: function()
{

parent.fadeOut('normal', function() {$(this).remove();});

}

});

}

return false;
});



Also, how could I make the text disapear faster? It waits a while to fade out.