ajax呼び出しが成功した後、テーブル行を削除しようとしていますが、機能していません。ファイアバグにエラーはありません。バックエンドPHPの行を削除しますが、trは削除しません。これが私のコードです:
function closelead(rowid){
var rowid = rowid;
$.ajax({
type: "POST",
url: "ajax/close.php",
data: "rowid="+ rowid,
success: function(html){
$(this).closest('tr').remove();
}
});
}
およびhtml:
<table id="companytable">
<tr id="top"><th>Business Name</th><th>Phone</th><th>Carrier</th><th>X-Date</th><th></th><th></th><th></th></tr>
<?php
$query = "SELECT * FROM leads WHERE user = '$user' ORDER BY wccompcode";
$selectlead = mysql_query($query)or die(mysql_error());
while($leadlist = mysql_fetch_array($selectlead)){
$compcode = $leadlist['wccompcode'];
$compcode = sprintf("%03s", $compcode);
$selcomp = mysql_query("SELECT carname FROM carrierlist WHERE carcode = '$compcode'")or die(mysql_error());
while($carrier = mysql_fetch_array($selcomp)){
$carrier1 = $carrier['carname'];
}
?>
<tr id="<?php echo $leadlist['ID'];?>"><td id="busname"><?php echo $leadlist['busname'];?></td><td><?php echo $leadlist['phone'];?></td><td><?php echo $carrier1;?></td><td><?php echo date("m/d/Y",strtotime($leadlist['wcxdate']));?></td><td><input type="button" value="Call Back" class="searchbutton" /></td><td><input type="button" onclick="closelead(<?php echo $leadlist['ID'];?>)" value="Close" class="searchbutton" /></td><td><input type="button" value="Soft Quote" class="searchbutton" /></td></tr>
<?
}
?>
</table>