小编sai*_*jie的帖子

ajax完成后如何使Sweet alert自动关闭?

我正在使用甜蜜警报,但如果 ajax 的请求完成,我想让它自动关闭

swal({
  title: "Are you sure?",
  text: "You are choosing order by custom search",
  type: "warning",
  showCancelButton: true,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "Confirm",
  closeOnConfirm: false,
  timer: **AUTO WITH AJAX??**
},
Run Code Online (Sandbox Code Playgroud)

我正在添加一个变量

var dones = $(document).ajaxComplete(function(){
                            swal.close()
                        });
Run Code Online (Sandbox Code Playgroud)

并像这样制作 swal

swal({
  title: "Are you sure?",
  text: "You are choosing order by custom search",
  type: "warning",
  showCancelButton: true,
  confirmButtonColor: "#DD6B55",
  confirmButtonText: "Confirm",
  **timer: dones,**
  closeOnConfirm: false
},
Run Code Online (Sandbox Code Playgroud)

但仍然不像我预期的那样

php ajax sweetalert sweetalert2

1
推荐指数
1
解决办法
6202
查看次数

标签 统计

ajax ×1

php ×1

sweetalert ×1

sweetalert2 ×1