当我单击“删除”按钮时,我试图使用甜蜜警报在我的应用程序中创建删除确认,因此我在控制台上遇到错误未捕获的TypeError:无法将类作为函数调用 >
请建议如何解决此错误?
控制器
public function destroy($id)
{
$delete = Digitizing::where('id', $id)->delete();
if ( $delete == 1) {
$success = true;
$message = "User deleted successfully";
} else {
$success = true;
$message = "User not found";
}
}
HTML视图
<a class="btn btn-danger" onclick="deleteConfirmation({{$digitizing-
>id}})">Delete</a>
<script type="text/javascript">
function deleteConfirmation(id) {
swal({
title: "Delete?",
text: "Please ensure and then confirm!",
type: "warning",
showCancelButton: !0,
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel!",
reverseButtons: !0
}).then(function (e) {
if (e.value === true) {
var CSRF_TOKEN = $('meta[name="csrf-
token"]').attr('content');
$.ajax({
type: 'POST',
url: "{{url('/delete')}}/" + id,
data: {_token: CSRF_TOKEN},
dataType: 'JSON',
success: function (results) {
if (results.success === true) {
swal("Done!", results.message, "success");
} else {
swal("Error!", results.message, "error");
}
}
});
} else {
e.dismiss;
}
}, function (dismiss) {
return false;
})
}
</script>
答案 0 :(得分:2)
这是因为代码的.ace_highlight {
background-color: yellow;
}
部分。
Swal是课程的名称。您将要用swal({
替换它。
此外,请注意,在两种情况下,您的php代码都将返回Swal.fire(
。您可能还想更新它。