如何通过一次提交提交多个表单?
我在同一页面上有多个表单,但我想将所有表单一起提交一次,而不是一次提交一个。我的方法是将所有数据克隆到另一个表单中并立即提交,但这会产生一定的开销。那么,有没有另一种方法可以一次性提交多个表单数据。
预先感谢您的任何帮助。
I have multiple forms on the same page but I want to submit all forms together once instead of submitting one at a time. My approach is to clone all the data inside a another form and submit at once but its kind of overhead . So, is there a another approach to submit multiple form data once.
Thanks in advance for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当单击
'button'
时,这将通过 ajax 提交所有表单元素。请注意,这不会刷新页面,因为它们都是通过 ajax 提交的...
This will submit all form elements via ajax when
'button'
is clickedNote that this will not refresh the page, as they are all submitted via ajax...
嗯嗯。这听起来可能很激烈,但为什么不将所有
INPUT
封装到一个FORM
元素中呢?如果不是这样,我认为您将不得不依靠 AJAX 来为您完成此操作。Hmmmm. This might sound drastic, but why not encapsulate all the
INPUT
s into just oneFORM
element? If not that, I think you'll have to rely on AJAX to do this for you.您可以按照您的方式进行操作,也可以通过 ajax 请求提交表单。如果不需要异步,我可能会按照您计划的方式进行。
You could either do it the way that your doing it, or you can submit the forms via ajax requests. If there is no need for it to be asynchronous, I would probably do it the way you plan on doing it.