What is the reason why forms are submitted twice in layui?
This article mainly shows you "what is the reason why the form is submitted twice in layui", the content is simple and clear, and I hope it can help you to solve your doubts. Let the editor lead you to study and learn "the reason why there are two form submissions in layui".
(1) when you use layui to submit twice, you will think that there is no return false when binding on sumit, which leads to the failure to intercept the normal submission method and visit action again.
If you want to know more about layui.
Form.on ('submit (formDemo)', function (data) {var fd = new FormData ($('form') [0]) $.ajax ({type: "POST", url:'/ admin/adduser.do', data: fd, async: false, cache: false, contentType: false, processData: false Success: function (res) {if (res.status = = 200) {layer.msg (res.msg, {time: 2000}) Var url = "/ admin/views/users.html"; / / Jump setTimeout (function () {_ window.location.href = url}, 2000);} else {layer.msg (res.msg, {time: 2000}) }); return false; / / this paragraph is very important})
(2) however, this is not my problem. I visited the back-end interface twice, and it was very strange. After debugging the front end, I found that the layui.all.js was referenced again, that is, if the page was rendered twice, of course it was submitted twice.
The above is all the content of the article "Why are the forms submitted twice in layui?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!