甜蜜警报无法正常工作

时间:2018-04-29 05:43:24

标签: jquery ajax sweetalert2

我正在使用sweetalert在ajax响应成功时显示消息,但它没有正确显示,即没有显示成功图标。

  

这是我的ajax代码

var formData = $("#enqform").serialize();
      jQuery.ajax({
          type: 'POST',
          url: '<?php echo base_url() ?>tour-package/send-mail',
          data: formData,
          dataType: 'json',
          success: function(data){
            if(data.status == 1){
                swal({
                      title: "Thankyou!",
                      text: "Our excecutives will contact you soon.",
                      icon: "success",
                    });
                window.setTimeout(function() {
                    window.location.href = '<?php echo base_url() ?>tour-packages';
                }, 100000);
            }
            else{
                swal("Error occured !");
            }
          }
      }); 
      return false;
      e.preventDefault();
  }

https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.19.2/sweetalert2.min.css

https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.19.2/sweetalert2.min.js

我正在使用这些css和js访问sweetalert。

2 个答案:

答案 0 :(得分:4)

更改图标键入对我有用

swal({
  title: "Thankyou!",
  text: "Our excecutives will contact you soon.",
  type: "success",
});

答案 1 :(得分:0)

试试这个:

&#13;
&#13;
var formData = $("#enqform").serialize();
      $.ajax({
          type: 'POST',
          url: '<?php echo base_url('tour-package/send-mail') ?>',
          data: formData,
          dataType: 'json'

          ).done(function(data)
          {
            if(data.status == 1){
                swal({
                      title: "Thankyou!",
                      text: "Our excecutives will contact you soon.",
                      icon: "success",
                    });
                window.setTimeout(function() {
                    window.location.href = '<?php echo base_url('tour-packages')?>';
                }, 100000);
            }
            else{
                swal("Error occured !");
            }
          });
       });
&#13;
&#13;
&#13;