Home > Article > Web Front-end > How to solve layui form submission twice
“The bad layui form will be submitted twice, have you encountered it?
”
“If you want to know the solution directly, just go to the third section.”
This is the effect that has been achieved, before it was No, it's just the result of adding this thing.
I don’t know how you usually find the code for development. Kaka directly goes to the code library and searches directly The link format is incorrect
.
The picture below is the result of Kaka search, so the next step is to introduce this js file and try it!
So I picked up the keyboard and imported this file into it
is the original cause of the problem!
Add a piece of data
did not disappoint, two pieces of data appeared, haha! Confused
actually appears This problem is caused by carelessness, and still unfamiliar with the layui framework.
The solution is to kill the form js file. Isn’t it funny? Yes! Very funny.
You will suddenly realize when you open the layui.js file
It turns out that layui.js automatically includes all modules I imported the module locally, so this happens.
Of course the problem is not just the case of Kaka.
If you reference the layui.all.js file twice in a row, it will trigger twice in a row, or reference the layui.all.js file first, and then reference the layui.js file and it will trigger twice. Please be careful. Check the files you reference!!!
After referencing the layui.all.js file, layui.js is referenced again, causing it to be triggered twice in a row!
“Persistence in learning, persistence in blogging, and persistence in sharing are the beliefs that Kaka has always upheld since his career. I hope that Kaka’s articles on the huge Internet can bring you a little help. I am Kaka, see you in the next issue.
”
The above is the detailed content of How to solve layui form submission twice. For more information, please follow other related articles on the PHP Chinese website!