当用户单击“取消”按钮时,我创建了用于删除表单的AJAX方法。
$(document).on('click', '.delete_ajax_nfdocs', function () {
var myId = $(this).attr('data-id');
swal({
title: "Are you sure?",
text: "Your changes will not be saved.",
type: "warning",
showCancelButton: true,
cancelButtonText: "No, stay here.",
confirmButtonColor: "#FF7043",
confirmButtonText: "Yes, cancel it!",
closeOnConfirm: true,
showLoaderOnConfirm: true,
},
function () {
$.ajax({
type: "post",
url: "/Nfdocuments/onCancel",
data: { id: myId },
success: function () {
window.location.href = 'Create'
},
error: function (data) {
swal("Oops", "Something went wrong!", "error");
}
});
})
});
当我单击console.log中的CANCEL按钮时,我会出错
POST http://localhost:49931/Nfdocuments/onCancel 500 (Internal Server Error)
我检查了功能中的所有内容,但无法弄清楚哪里出错了。 有帮助吗?