我在页面中有一个表,例如:-
<tr>
<th>no</th>
<th>name</th>
<th>age</th>
<th>actions</th>
</tr>
<tr>
<td>$i</td>
<td>$name</td>
<td>$age</td>
<td><a href="$id" class="delete">Delete</a></td>
</tr>
在点击删除时,它将使控制器通过jquery并成功删除该行,之后我想显示更新的表意味着没有删除的行。对于这个,我现在使用另一个页面和表格数据,在成功的时候我这样做:
$(.updated_table_view).html(data.view);
有没有其他简单的方法可以做到这一点,就像没有另一个页面一样?
大概"…将通过jquery…">的意思是通过Ajax,所以如果你想让它只做一个简单的删除,只需隐藏行:
jsFiddle:https://jsfiddle.net/842x2wuc/
<script>
$(document).ready(function(){
$('.delete').click(function(e) {
e.preventDefault();
var thisBtn = $(this);
$.ajax({
url: '/link/to/delete.php',
type: 'post',
data: { id: thisBtn.attr('href') },
success: function(response) {
// This will fade out the row
thisBtn.closest('tr').fadeOut('fast');
}
});
});
});
</script>