jQuery Sweet Alert 意外的第二个参数错误
jQuery Sweet Alert Unexpected 2nd argument error
我在使用 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.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>
我在控制台上的整个错误 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);
})
甜蜜提醒可以通过两种方式调用
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!",
});
如果你想对响应做一些事情,它 returns 一个承诺,你可以用 .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);
});
我在使用 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.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>
我在控制台上的整个错误 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);
})
甜蜜提醒可以通过两种方式调用
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!", });
如果你想对响应做一些事情,它 returns 一个承诺,你可以用 .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);
});