Javascript jQuery甜警报意外的第二个参数错误
我正在使用sweet alert插件,但出现了一个错误。我已经尝试了每一个例子,但不明白这个错误意味着什么 未捕获的SweetAlert:意外的第二个参数(函数(){ setTimeout(函数(){ckquote 我的代码:Javascript jQuery甜警报意外的第二个参数错误,javascript,jquery,sweetalert,Javascript,Jquery,Sweetalert,我正在使用sweet alert插件,但出现了一个错误。我已经尝试了每一个例子,但不明白这个错误意味着什么 未捕获的SweetAlert:意外的第二个参数(函数(){ setTimeout(函数(){ckquote 我的代码: <script type="text/javascript"> $('.delete-confirm').on('click', function() { var postID = $(this).val(); console.log(post
<script type="text/javascript">
$('.delete-confirm').on('click', function() {
var postID = $(this).val();
console.log(postID);
swal({
title: "Are you sure?",
text: "If you delete this post all associated comments also deleted permanently.",
type: "warning",
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
}, function() {
setTimeout(function() {
$.post("../delete.php", {
id: postID
},
function(data) {
swal({
title: "Deleted!",
text: "Your post has been deleted.",
type: "success"
},
);
}
);
}, 50);
});
});
</script>
可以通过两种方式调用Sweet Alert
- 1、2或3个字符串参数
swal(["title",] "text" [, "iconname"])
- 包含所有选项的单个对象参数:
swal({ title: "Are you sure?", text: "If you delete this post all associated comments also deleted permanently.", type: "warning", showCancelButton: true, closeOnConfirm: false, showLoaderOnConfirm: true, confirmButtonClass: "btn-danger", confirmButtonText: "Yes, delete it!", });
检索该值。然后:
swal({
title: "Are you sure?",
text: "If you delete this post all associated comments also deleted permanently.",
type: "warning",
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
}).then(function() {
setTimeout(function() {
$.post("../delete.php", {
id: postID
},
function(data) {
swal({
title: "Deleted!",
text: "Your post has been deleted.",
type: "success"
}, );
}
);
}, 50);
});
看起来sweet alert不接受第二个参数,因此传入'function(){location.reload();}`因为第二个参数是不允许的,他们对它进行了编程,让您知道。@dave我删除了重新加载函数,但仍然出现上述错误非常感谢,我现在理解了这个概念。非常感谢
swal({
title: "Are you sure?",
text: "If you delete this post all associated comments also deleted permanently.",
type: "warning",
showCancelButton: true,
closeOnConfirm: false,
showLoaderOnConfirm: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
}).then(function() {
setTimeout(function() {
$.post("../delete.php", {
id: postID
},
function(data) {
swal({
title: "Deleted!",
text: "Your post has been deleted.",
type: "success"
}, );
}
);
}, 50);
});