我想通過單擊刪除按鈕來刪除一行。我已經(jīng)完成了編輯行中的數(shù)據(jù)。我想刪除行中的數(shù)據(jù)。并且刪除操作不起作用。 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.刪除功能不起作用。請(qǐng)幫助我。
- 2 回答
- 0 關(guān)注
- 198 瀏覽
添加回答
舉報(bào)
0/150
提交
取消
