The Layer plugin implements a warning prompt and turn off the pop-up layer in the pop-up layer.

Yesterday, the Layer plug-in pop-up layer closed the problem, I was screaming, just a few lines of code, I used me to solve nearly 2 hours. My use scene is like this. In the page, one layer is popped up with Layer.Open, which is the WeChat payment QR code, and the customer scan is paid. After the payment is successful, turn off the pop-up layer and prompt the item delivery to be successful, then jump to other pages. In order to monitor whether the WeChat QR code scan code payment is successful. I used it every three seconds, and the payment status of the payment order is changed every three seconds. In practice, because of the use of Location.href, doing jump, however, the jump execution is very slow, and it is necessary to succeed in 10 seconds. It can only be returned to the second, but it is prompted to be delivered successfully, then turn off the pop-up layer. Due to the closing the pop-up layer, the related code that pops up a warning prompt is executed on the page where the pop-up layer is located.

The actual code encountered various problems in the implementation process.

  $ (function () {setInterval (GetDeliverProjectPayStatusSuccess, 3000);}); function GetDeliverProjectPayStatusSuccess () {$ .post ( "/ ajax / GetDeliverProjectPayStatus.ashx", { ORDERNO: ""}, function (data) {console.info (data); if (data == 1) {parent.layer.closeall (); layer.alert ("Project delivery success");}} );}  
The first attempt is as follows. Turn off the pop-up layer first, then prompt project delivery. The result of this attempt was that the pop-up layer was turned off. Nothinghint. Why this execution, the result of the analysis is to close the popup, pop-up means that the page is closed. Pop-up page is closed. layer.alert code pop-up page exists there can be no execution. Then two lines exchange position. It can still pop layer is closed. It did not prompt. For this reason analysis it is like in javascript alert and location.href same. If the first alert then location.href, it will not perform alert, or that there are actually implemented, but due to the implementation of the system is very fast, and before you see the alert message, the browser has to jump up. Here also, before you see the success of the project delivery information, the popup has been closed.

and try a callback function layer.alert, such as customer clicks the OK button after the implementation of layer.alert parent.layer.closeAll () to close the popup. However, the harsh reality is that this is due to perform a post request every three seconds, the result is that if you click the Close button too slow, it will pop up three seconds every project delivery success tips. How it can be used. Do you require customers to have rapid response, click the Close button? After continuous attempts, finally we found a way to solve this problem.

This problem can be solved in the following code:

$ (function () {setInterval (GetDeliverProjectPayStatusSuccess, 3000);}); function GetDeliverProjectPayStatusSuccess ( ) {$ .post ( “/ ajax / GetDeliverProjectPayStatus.ashx”, {OrderNo: “
"}, function (data) {console.info (data); if (data == 1) {Parent.Layer.alert ("Project Delivery Success"); var index = parent.Layer.getFrameIndex (Window.Name); // get the index of the current IFrame layer Parent.Layer.close (INDEX); // }} (123)    
The method of the Layer plug-in is implemented in the pop-up layer and the method of turning off the pop-up layer is that the total content of Xiaobian sharing. I hope to give you a reference, I hope everyone will support Tumi Cloud.
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment