我正在尝试将jsp
页面中的表格传递给删除确认的引导模式..
这是我的按钮:
<button class="btn btn-danger btn-xs" data-title="Delete" data-toggle="modal" data-target="#confirm-delete" data-delete ="${user.id}">
<span class="glyphicon glyphicon-trash"></span>
这是模态:
<div class="modal fade" id="confirm-delete" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
</div>
<div class="modal-body">
<p>You are about to delete a User, this procedure is
irreversible.</p>
<p>Do you want to proceed ?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger btn-ok" id="delBtn">Delete</button>
</div>
</div>
</div>
</div>
这是我用来调用delete
url:
$('#confirm-delete').on('show.bs.modal', function(e) {
$('#delBtn').click(function() {
$(document).ready(function() {
var deleteid = $(e.relatedTarget).data('delete');
$.ajax({
cache: false,
type: 'POST',
url:"<c:url value='/supprimer/" + deleteid + "'/>",
data: ,
success: function(data)
{
}
});
});
});
});
这是调度员控制器:
@RequestMapping("/supprimer/{id}")
public String removeUser(@PathVariable("id") int id){
this.userService.deleteData(id);
return "redirect:/utilisateurs";
}
我的工作似乎是逻辑:/但我不知道为什么这不起作用?
我也试过这个script
,但它不起作用:
$('#confirm-delete').on('show.bs.modal', function(e) {
var deleteid = $(e.relatedTarget).data('delete');
alert(deleteid);
$('#delBtn').attr('onClick', "location.href="<c:url value='/supprimer/" + deleteid + "'/>"");
});
请帮忙吗?
答案 0 :(得分:0)
此脚本完全颠倒了
Warning: exif_read_data('/local/path/to/file'): Illegal IFD size
整个脚本应位于$('#confirm-delete').on('show.bs.modal', function(e) {
$('#delBtn').click(function() {
$(document).ready(function() {
var deleteid = $(e.relatedTarget).data('delete');
$.ajax({
cache: false,
type: 'POST',
url: "<c:url value='/supprimer/" + deleteid + "'/>",
data: ,
success: function(data) {}
});
});
});
});
上面的脚本应该是
$(document).ready(function() {}
在你的第二个剧本中,用你的方法
$(document).ready(function() {
$('#confirm-delete').on('show.bs.modal', function(e) {
var deleteid = $(e.relatedTarget).data('delete');
$('#delBtn').click(function() { //beter if use `onClick` function
$.ajax({
cache: false,
type: 'POST',
url: "<c:url value=/supprimer/" + deleteid + "/>", //there were also extra commas here
data: ,
success: function(data) {}
});
});
});
});
或尝试这样
$('#confirm-delete').on('show.bs.modal', function(e) {
var deleteid = $(e.relatedTarget).data('delete');
alert(deleteid);
$('#delBtn').attr('onClick', "location.href='<c:url value=/supprimer/" + deleteid + "/>'");
});
脚本中有额外逗号的问题,应检查控制台并呈现HTML