我试图在数据传递时显示 swal 成功消息。即使数据已传递,我也没有得到 swal,这显示在 chrome 控制台中
Uncaught ReferenceError: swal is not defined success @ CustomerLoyalty:40 (anonymous function) @ CustomerLoyalty:217
第 40 行:
<script>
function alerts() {
swal({ title: "Are you sure you want to delete?", text: "You will not be able to recover this record!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Delete", closeOnConfirm: false }, function(){ swal("Deleted!", "Employee Record has been deleted", "success"); });
}
function success() {
swal("Warning!","Failed to record leave!", "success")
}
</script>
上面是我的 swal 函数,当我单击控制台中的错误时,“swal(“警告!”,“无法记录离开!”,“成功”)”以红色下划线显示。 (见截图)
第 217 行:
<form role="form" method="POST" action="http://localhost:8000/CustomerLoyalty">
<script type="text/javascript">success();</script>
谁能告诉我这里出了什么问题吗?我也将 swal 链接粘贴到我的标题中。 screenshot:
最佳答案
如果 swal 本身显示为未定义,则 swal 脚本根本无法加载。加载时检查网络选项卡,看看 swal js 是否已加载。
关于javascript - swal没有出现,但是数据传递了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39536345/