zoukankan      html  css  js  c++  java
  • h ui layui ajax 弹框 关闭 刷新

    jQuery.Vlidate 验证+ajax+layer的弹窗的关闭,刷新父窗口

     1   $("#form-member-edit").validate({
     2                 rules:{
     3                     username:{
     4                         required:true,
     5                         minlength:2,
     6                         maxlength:16
     7                     },
     8                     realname:{
     9                         required:true
    10                     },
    11                     password: {
    12                         required: true,
    13                         minlength: 5
    14                     },
    15                     password_confirmation: {
    16                         required: true,
    17                         equalTo: "#password"
    18                     },
    19                     sex:{
    20                         required:true
    21                     },
    22                     phone:{
    23                         required:true,
    24                         isMobile:true
    25                     }
    26 //                    email:{
    27 //                        required:true,
    28 //                        email:true,
    29 //                    },
    30                 },
    31                 messages:{
    32                     username:{
    33                         required:'用户名都不写,想干啥?',
    34                         minlength: "用户名至少由两个字母组成",
    35                         maxlength: "写那么多记得住吗?最多16位"
    36                     },
    37                     realname:{
    38                         required:'填姓名 啊'
    39                     },
    40                     password:{
    41                         required:'密码都不写,想干啥?',
    42                         minlength: "密码至少由五个字母组成"
    43                     },
    44                     password_confirmation: {
    45                         required: '必填的',
    46                         equalTo: "两次密码不一致"
    47                     },
    48                     sex:{
    49                         required:'必填'
    50                     },
    51                     phone:{
    52                         required:'必填',
    53                         isMobile:'请输入正确的电话格式'
    54                     },
    55 //                    email:{
    56 //                        required:'必填',
    57 //                        email:'请输入正确的邮箱格式',
    58 //                    },
    59                 },
    60                 onkeyup:false,
    61                 focusCleanup:true,
    62                 success:"valid",
    63                 submitHandler:function(form){
    64                     var index = parent.layer.getFrameIndex(window.name); //这里也可以注释掉
    65                     $(form).ajaxSubmit({
    66                                 type: 'PUT',
    67                                 url: 'URL',
    68                                 data:{
    69                                     '_token':'{{csrf_token()}}'
    70                                 },
    71                                 dataType: 'json',
    72                                 success: function(data){
    73                                     if(data.status===10007)
    74                                     {
    75                                         layer.msg(data.msg,{icon: 1,time:1000},function(){
    76                                             //parent.layer.close(index);   父窗口的关闭可以导致弹窗的关闭,所以  此处 注释了
    77                                             parent.location.reload();
    78                                         });
    79                                     }
    80                                 },
    81                                 error:function(data) {
    82                                     if(data.status===10008)
    83                                     {
    84                                         layer.msg(data.msg,{icon: 2,time:1000},function(){
    85                                             parent.location.reload();
    86                                         });
    87                                     }
    88                                     else
    89                                     {
    90                                         layer.msg('未知错误',{icon: 3,time:1000},function(){
    91                                             parent.location.reload();
    92                                         });
    93                                     }
    94                                 }
    95                             });
    96 
    97 //                    parent.location.reload();
    98                 }
    99             });
  • 相关阅读:
    uva 1606 极角扫描
    Codeforces Round #304 (Div. 2) 题解
    Codeforces Round #306 (Div. 2) 题解
    Codeforces Round #299 (Div. 2) 题解
    树链剖分专题
    bzoj 1036: [ZJOI2008]树的统计Count
    bzoj 1007: [HNOI2008]水平可见直线
    bzoj 1003: [ZJOI2006]物流运输trans
    Codeforces Round #301 (Div. 2) 题解
    bzoj 1026: [SCOI2009]windy数
  • 原文地址:https://www.cnblogs.com/zqblog1314/p/12655790.html
Copyright © 2011-2022 走看看