admin管理员组文章数量:1405370
I am using sweet alert plugin and getting an error. I have tried every example but can't understand what this error means
Uncaught SweetAlert: Unexpected 2nd argument (function() { setTimeout(function() {ckquote
My code:
<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 ments 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>
My whole error on console window:
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);
})
I am using sweet alert plugin and getting an error. I have tried every example but can't understand what this error means
Uncaught SweetAlert: Unexpected 2nd argument (function() { setTimeout(function() {ckquote
My code:
<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 ments 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>
My whole error on console window:
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);
})
Share
Improve this question
edited Apr 20, 2018 at 22:59
sach jot
asked Apr 20, 2018 at 22:52
sach jotsach jot
5704 silver badges18 bronze badges
2
- 1 it looks like sweet alert doesn't take a second argument, so passing in ` function() { location.reload(); }` as the second argument isn't allowed, and they programmed it to actually let you know. – dave Commented Apr 20, 2018 at 22:56
- @dave I removed the reload function but still go the above error – sach jot Commented Apr 20, 2018 at 23:00
1 Answer
Reset to default 4Sweet Alert can be invoked in two ways
1, 2, or 3 strings parameters
swal(["title",] "text" [, "iconname"])
a single object parameter containing all the options:
swal({ title: "Are you sure?", text: "If you delete this post all associated ments also deleted permanently.", type: "warning", showCancelButton: true, closeOnConfirm: false, showLoaderOnConfirm: true, confirmButtonClass: "btn-danger", confirmButtonText: "Yes, delete it!", });
If you want to do something with the response, it returns a promise, and you can retrieve the value with .then
:
swal({
title: "Are you sure?",
text: "If you delete this post all associated ments 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);
});
本文标签: javascriptjQuery Sweet Alert Unexpected 2nd argument errorStack Overflow
版权声明:本文标题:javascript - jQuery Sweet Alert Unexpected 2nd argument error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744894760a2630995.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论