Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-成功注册后显示SweetAlert模式弹出窗口(AJAX)_Php_Ajax_Registration - Fatal编程技术网

PHP-成功注册后显示SweetAlert模式弹出窗口(AJAX)

PHP-成功注册后显示SweetAlert模式弹出窗口(AJAX),php,ajax,registration,Php,Ajax,Registration,我希望这样,当我的ajax代码没有返回错误时,我就可以得到模态。我所有的代码都工作得很好,我只需要知道一旦没有错误,如何创建模式弹出窗口。我有一个ajax成功:函数,但我不确定这段代码将如何工作,因为目前,它只在单击按钮时工作 我正在使用SweetAlert JS文件 我的代码: 单击按钮时的工作模式: !函数(e){“严格使用”; var t=函数(){}; t、 prototype.init=函数(){ e(“#sa success”)。单击(函数(){ swal(“注册成功”,“您的注册

我希望这样,当我的ajax代码没有返回错误时,我就可以得到模态。我所有的代码都工作得很好,我只需要知道一旦没有错误,如何创建模式弹出窗口。我有一个ajax成功:函数,但我不确定这段代码将如何工作,因为目前,它只在单击按钮时工作

我正在使用SweetAlert JS文件

我的代码:

单击按钮时的工作模式:


!函数(e){“严格使用”;
var t=函数(){};
t、 prototype.init=函数(){
e(“#sa success”)。单击(函数(){
swal(“注册成功”,“您的注册成功!检查您的电子邮件并单击您的激活链接以访问您的帐户。”,“成功”)
}
)
},e.SweetAlert=new t,e.SweetAlert.Constructor=t}(window.jQuery),函数(e){“使用严格”;e.SweetAlert.init()}(window.jQuery);
我的AJAX注册码我想弹出一次模式窗口msg='':


$(文档).ready(函数(){
addMethod(“noSpace”,函数(值,元素){
返回值.indexOf(“”<0&&value!=“”);
},“不允许使用空格”);
$(“#注册表格”)。提交(函数(){
如果($(“#注册表格”).valid()){
var data1=$(“#已注册的_形式”).serialize();
$.ajax({
类型:“POST”,
url:“inc/pgs/register.php”,
数据:数据1,
成功:功能(msg){
控制台日志(msg);
如果(消息=“”){
//setTimeout(“window.location.href='login.php';”,4000);
}否则{
$(“#结果”).html(“”+msg+“”).slideDown(100);
setTimeout(函数()
{
$(“.alert”).fadeTo(500,0).slideUp(500,function(){
$(this.remove();
});
}, 3000);
}
}
});
}
返回false;
});
});

全部已排序。我必须看SweetAlert手册才能知道它是如何工作的。我以前应该检查一下的

我只需要使用:

swal("Registration Success!", "Your registration was successful! Check your email and click on your activation link to be able to access your account.", "success");
    <script>
        $(document).ready(function() {

    jQuery.validator.addMethod("noSpace", function(value, element) { 
     return value.indexOf(" ") < 0 && value != ""; 
  }, "Spaces are not allowed");

            $("#registered_form").submit(function() {

                if ($("#registered_form").valid()) {
                    var data1 = $('#registered_form').serialize();
                    $.ajax({
                        type: "POST",
                        url: "inc/pgs/register.php",
                        data: data1,
                        success: function(msg) {
                            console.log(msg);
                            if(msg == '') {
                                //setTimeout("window.location.href='login.php';",4000);
                            } else {
                                $("#result").html('<div class="alert alert-danger"><button type="button" class="close"></button>' + msg +'</div>').slideDown(100);
                                window.setTimeout(function()
                                {
                                    $(".alert").fadeTo(500, 0).slideUp(500, function(){
                                        $(this).remove(); 
                                    });
                                }, 3000);
                            }
                        }
                    });
                }
                return false;
            });
        });
    </script>
swal("Registration Success!", "Your registration was successful! Check your email and click on your activation link to be able to access your account.", "success");