Layui close the popup and refresh the parent window

First ensure you have introduced layui and jquery

Then ensure that the initialization layer pop-up layer

<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form;
        var layer = layui.layer;

    });
</script>

A first type:

$ (function () { 
// Close popup 
        $ (Document) .on ( 'the Click', '#closeBtn', 
            function () { 
                var index = parent.layer.getFrameIndex (the window.name); // get the current first iframe index layer 
                parent.location.reload (); // refresh the parent page, attention must be executed before closing the current refresh iframe layer 
                parent.layer.close (index); // then perform closed 
            }); 
});

2 ways:

   . $ ( '# Pass') the Click (function () { 
              var Quantity = $ ( '# upd_chengyijin') Val ();. 
              IF (Quantity) {! 
                  layer.msg ( 'Please fill in the data', { 
                         icon: 2, 
                         time: 500 // 2 seconds off (if not configured, the default is 3 seconds) 
                         }, function () { 

                         }); 
                  return to false; 
              } 
              $ .ajax ({ 
                  URL: 'updSincerity_money', 
                  type: 'the GET', 
                  Data: "Money =" + Quantity, 
                  Success: function (Data) { 
                      var index = parent.layer.getFrameIndex (the window.name);// get the first index of the current layer iframe 
                      parent.location.reload (); // refresh the parent page, attention must be closed before the current refresh iframe layer
                      parent.layer.close (index); // Close then execute 
                  } 
              }); 
          });

 

Guess you like

Origin www.cnblogs.com/yang101/p/11454530.html