这是我调用 Swal 的代码:
window.swal({
title: "Checking...",
text: "Please wait",
imageUrl: "{{ asset('media/photos/loaderspin.gif') }}",
showConfirmButton: false,
allowOutsideClick: false
});
$.ajax({
type: 'POST',
url: '/' + target,
data: {
data: true
},
success: function(response) {
window.swal({
type: 'info',
width: 900,
padding: '3em',
html: response,
showCloseButton: true,
focusConfirm: false,
});
},
error: function(response) {
}
});
基本上我正在发出一个 ajax 请求,执行 return view('index', compact('data'));
在 Controller 中。
我尝试在 Swal 中加载的 html 有一个 <script src="my-file.js"></script>
在其中,但当 Swal
时它不会被加载已被触发,因此当我单击内部时不会触发任何事件。
我尝试查看文档,但找不到任何内容。我如何让 swal 加载该文件?
最佳答案
我能够通过在 success
block 中添加此行来解决此问题:
$.getScript('my-file.js')
关于javascript - 在 Sweet Alert 中加载 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57073793/