jquery submit multiple forms

别等时光非礼了梦想. 提交于 2019-11-29 16:14:55

If one form relies on two other forms, it sounds like they're really part of the same form, and the backend should just figure out which parts of that one mega-form (with different sets of data, but for one form) that are needed. On a similar note, it's best not to rely on javascript alone anyway, so doing it this way provides you with an automatically more robust solution.

Update If you have multiple forms that are just sharing data (like they can change data on form1 and form2 that form3 needs), it would be more stable, especially in light of validation, to put those shared things in hidden elements and leave the forms separate. Having users enter data that will be submitted and used and then hiding it from view isn't optimal, since they can more easily make entry mistakes (they can't review as easily and they may not understand it will all be submitted). Using < input type="hidden" />s for shared info alleviates this because they won't be able to accidentally change it. (Or store it in the session or whatever you'd like. Point is, prevent them from changing info that you're going to rely upon and they can't easily spot mistakes in.)

Since the form is submitted and you are navigating away from the page you could remove the unnecessary fields before submitting. Only one form will be necessary.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!