This is the function
function deleteItem(id) {
$.post("_asyncpage.php",
{id:id},
function (result) {
if (result == true) {
$('#'+id).remove();
}
}, "json");
}
So, to explain, the function receive an id, send to a page that execute random stuff on a db and return true/false.
The function inside check for result that can be true/false as said before.
If true proceed to remove the dom element that match the id passed.
The db is updated correctly but the .remove() won’t work… someone knows why? 🙁
The following is an example of the html structure. the table inside the TD is the one to be deleted.
<td width="120" valign="top" id="13_02">
<table cellspacing="0" cellpadding="0" class="tableProg" id="1">
<tbody>
<tr>
<td colspan="3"><h4 style="margin: 0pt;">Title</h4></td>
</tr>
<tr>
<td colspan="3">h. 13:35</td></tr><tr><td width="74"><span style="font-weight: bold; color: rgb(0, 102, 204);">Su</span>: TV</td>
<td width="22"><a href="javascript:openEditItem('2010/08/24','1')"><img src="static/images/edit.gif"></a></td>
<td width="22"><a href="javascript:deleteItem('1')"><img src="static/images/delete.gif"></a></td>
</tr>
</tbody>
</table>
</td>
Update: From the additional info you provided, the issue may be with your IDs. It is not valid for an ID to start with a number. This can cause problems.
If youridthat you’re passing to the function already has a#at the beginning, then you don’t want to concatenate it.Also, if the response you’re getting is a string, then you would want to compare the result to the string
'true'.