Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the reason why forms are submitted twice in layui?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report