[jQuery] Rudimentary jQuery question
Hi all,
So I'm trying to do something rather simple, but having difficulty
accomplishing it. I'm basically giving the user an option to delete a
row from a table within a div, using something similar to this on the
server-side:
if(mysql_num_rows($result) == 0) { exit; }
$html = '<table>';
$html .= '<tr>';
// count here basically just keeps track of a
// neatly aligned table
$count=0;
foreach($alpha_notes as $note) {
$html .= "<td><a href=\"javascript:void(0);\"
onclick=\"removeNote('".$note[ID]."','".$note[NAME]."')\">delete</a> $note[NAME]</td>";
$count++;
if(($count % 2 == 0)) {
$html .= "</tr><tr>";
}
}
$html .= '</tr></table>';
My issue is, if the user has deleted their 'last' available row, I
want something to come up such as "This table has no more information
left." I tried doing that with the following:
function removeNote(id,name) {
if(confirm("Are you sure you wish to delete: "+name+"?")) {
// ajax code here to remove note.
$.ajax({
url: "/dbserver.php",
type: "POST",
data: "delete="+id+"&db=alpha",
cache: false,
success: function(html) {
if(html==="FALSE") {
$("alpha_notes").empty().insert("There are no notes left in alpha.");
} else {
$("#alpha_notes").empty().append(html);
}
}
});
}
}
Any idea where I went wrong here? I'm assuming it's causing I'm
returning a data type of HTML so my if() construct here doesn't
logically make sense.
- sf