我试图在传递数据时显示swal成功消息。即使数据通过我也没有得到swal,这显示在chrome控制台
中未捕获的ReferenceError:未定义swal 成功@CustomerLoyalty:40 (匿名函数)@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功能和&#34; swal(&#34;警告!&#34;,&#34;未能记录假!&#34;,&#34;成功&#34;) &#34;当我点击控制台中的错误时,下划线为红色。 (见截图)
第217行:
<form role="form" method="POST" action="http://localhost:8000/CustomerLoyalty">
<script type="text/javascript">success();</script>
谁能告诉我这里有什么问题?我已经在标题中粘贴了swal链接。screenshot:
答案 0 :(得分:0)
如果swal
本身显示为undefined
,那么swal脚本dint会加载。加载时检查网络选项卡,看看是否加载了swal js。
答案 1 :(得分:0)
SOLVEDIT
<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"); });
}
<script>
function success() {
swal("Warning!","Failed to record leave!", "success");
}