求大神指教
html:
{% for student in all %}
<tr>
<th scope="col" id="{{ student.username }}">{{ student.username }}</th>
<th scope="col">{{ student.name }}</th>
<th scope="col">{{ student.gender }}</th>
<th scope="col">{{ student.phone }}</th>
<th scope="col">{{ student.addr }}</th>
<th scope="col">
<button type="submit" class="btn btn-secondary">编辑信息</button>
<button type="submit" class="btn btn-info" data-toggle="modal" data-target="#update_password">修改密码</button>
<button type="submit" class="btn btn-danger del_account">删除账号</button>
<div class="modal fade" id="update_password" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="text-danger">修改密码</h5>
</div>
<div class="modal-body">
<div class="form-group">
<lable for="recipient-name" class="col-form-label">请输入修改后的密码: </lable>
<input type="password" class="form-control">
</div>
<div class="form-group">
<lable for="recipient-name" class="col-form-label">请确认修改后的密码: </lable>
<input type="password" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary update_password">确认修改</button>
</div>
</div>
</div>
</div>
</th>
</tr>
js:
$(document).ready(function () {
$(".del_account").click(function () {
if (confirm("是否删除?")){
var username = $(this).parent("th").parent("tr").children(":first").attr('id');
$.ajax({
url:"/system/del_account",
type:"POST",
data:{'csrfmiddlewaretoken': $('[name="csrfmiddlewaretoken"]').val(),"username":username},
success:function (data) {
alert(username)
}
})
}
})
})
views: