我在 jquery-ajax 中有这个脚本来删除表中的一行,但不要在 db 中删除任何内容......只删除页面中表中的行......也许你无法帮助我......我尝试了两种形式,因为表 paciente 中的 id 是 id_paciente ...所以我尝试了这种形式:这是ajax 脚本:
<script type="text/javascript">
$(document).ready(function()
{
$('table#delTable td a.btn-danger').click(function()
{
if (confirm("Realmente desea borrar el registro del paciente?"))
{
var id = $(this).parent().parent().attr('id');
var data = '?id_paciente=' + id ;
var parent = $(this).parent().parent();
$.ajax(
{
type: "POST",
url: "delete.php",
data: data,
cache: false,
success: function()
{
parent.fadeOut('slow', function() {$(this).remove();});
}
});
}
});
// style the table with alternate colors
// sets specified color for every odd row
$('table#delTable tr:odd').css('background',' #FFFFFF');
});
</script>
还有这个:
code.....
var id = $(this).parent().parent().attr('id');
var data = 'id=' + id ;
var parent = $(this).parent().parent();
.....code
这是按钮:
<a class="btn btn-danger" id="<?php echo $row['id_paciente']; ?>" href="#" >
<i class="icon-trash icon-white"></i>
Borrar
</a>
这是delete.php
<?php
include_once("config.php");
$count=$conn->prepare("delete from PACIENTES WHERE id_paciente=:id_paciente");
$count->bindParam(":id_paciente",$id_paciente,PDO::PARAM_INT);
$count->execute();
?>