Я использую плагин sweet alert и получаю сообщение об ошибке. Я пробовал все примеры, но не могу понять, что означает эта ошибка
Uncaught SweetAlert: Unexpected 2nd argument (function() { setTimeout(function() {ckquote
Мой код:
<script type = "text/javascript">
$('.delete-confirm').on('click', function() {
var postID = $(this).val();
console.info(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>
Вся моя ошибка в окне консоли:
sweetalert.min.js:1 Uncaught SweetAlert: Unexpected 2nd argument (function() {
setTimeout(function() {
$.post("../delete.php", {
id: postID
},
function(data) {
swal({
title: "Deleted!",
text: "Your post has been deleted.",
type: "success"
},
);
}
);
}, 50);
})
@dave Я удалил функцию перезагрузки, но все еще продолжаю указанную выше ошибку



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


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!",
});
Если вы хотите что-то сделать с ответом, он возвращает обещание, и вы можете получить значение с помощью .then:
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);
});
Большое вам спасибо, теперь я понимаю концепцию.
Большое спасибо
похоже, что сладкое предупреждение не принимает второй аргумент, поэтому передача в `function () {location.reload (); } `поскольку второй аргумент недопустим, и они запрограммировали его так, чтобы вы знали.