Update table cell after link click
Hello,
I have a table with rows and in each row there is a cell which shows the status of the row item.
<a href="#" id="<?php id ?>" class="status_button">Online</a>
When I click the link in a row the next code is activated (found it somewhere on the net).
$(".status_button").click(function() {
var id = $(this).attr("id");
var dataString = 'id='+ id ;
var parent = $(this).parent();
$.ajax({
type: "POST",
url: "toggle_ajax.php", //updates the database
data: dataString,
cache: false,
success: function()
{
if(id % 2)
{
parent.fadeOut('slow', function() {$(this).remove();});
}
else
{
parent.slideUp('slow', function() {$(this).remove();});
}
}
});
The effect is that the status is changed in the database (toggle_ajax.php) and the table cell is removed (cell's on the right of this cell are moved 1 place to the left).
The effect that I want to get is that the cell is update with the new status.
How can this be accomplished?