【发布时间】:2014-11-20 09:02:07
【问题描述】:
我想要你的 - SweetAlert 我的网站。现在我需要使用此代码配置 SweetAlert,以便在单击“确定”按钮时,它将通过 POST formaction="/link/link" post="test=1"
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: " warning ",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: " No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm) {
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe: ) ", " error ");
}
});
我想问你,我该如何构建它。
【问题讨论】:
-
我假设您需要更改
if (isConfirm) {}部分。您可以使用所需字段创建新的form,将其附加到body,然后使用form.submit() -
你能给我写个例子吗?
-
@bigbobr 他没说他有表格。
-
@Nabil Kadimi,在你的回答中,
post()函数完全符合我在下面写的;) -
你在这个JS中使用了ajax
标签: javascript html sweetalert