我想通过单击删除按钮来删除一行。我已经完成了编辑行中的数据。我想删除行中的数据。并且删除操作不起作用。 db.php <script>$(document).ready(function() { $.ajax({ url: "View_ajax.php", type: "POST", cache: false, success: function(dataResult){ $('#table').html(dataResult); } }); $(document).on("click", ".delete", function() { var $ele = $(this).parent().parent(); $.ajax({ url: "delete_ajax.php", type: "POST", cache: false, data:{ id: $(this).attr("data-id") }, success: function(dataResult){ var dataResult = JSON.parse(dataResult); if(dataResult.statusCode==200){ $ele.fadeOut().remove(); } } }); });});</script>delete_ajax.php <?php include "php/dbConfig.php"; $id=$_POST['id']; $sql = "DELETE FROM `task` WHERE id=$id"; if (mysqli_query($conn, $sql)) { echo json_encode(array("statusCode"=>200)); } else { echo json_encode(array("statusCode"=>201)); } mysqli_close($conn); ?>view_ajax.php<td><input type='button' onclick="delete_user('<?php echo $row['id'];?>');" data-id="<?=$row['id'];?>" data-firstname="<?=$row['firstname'];?>" data-lastname="<?=$row['lastname'];?>" data-username="<?=$row['username'];?>" data-password="<?=$row['password'];?>" "></button></td>by clicking the delete button i want the entire row to be deleted.删除功能不起作用。请帮助我。
- 2 回答
- 0 关注
- 157 浏览
添加回答
举报
0/150
提交
取消