【发布时间】:2020-12-31 07:53:58
【问题描述】:
我有书目表,每一行都有书号,书名和删除按钮,将删除该书 我正在使用ajax进行删除,当我点击删除按钮时我遇到的问题总是删除表中的第一本书,任何帮助谢谢。
<table>
<thead>
<tr>
<th>Book NO</th>
<th>Book Name</th>
<th>Remove</th>
</tr>
</thead>
<tbody>
{% for book in book_List %}
<tr>
<td>{{book.no}}</td>
<td>{{book.name}}</td>
<td>
<form method="POST">
<input type="hidden" name="remove_uuid" value="{{ book.uuid}}">
<button onclick="delete()">Delete</button>
</form>
</td>
</tr>
{%endfor%}
</tbody>
</table>
脚本
function delet(){
$.ajax({
type:'POST',
data: $('form').serialize(),
success: function (data) {
alert("the book has been delete it")
}
}
【问题讨论】: