How to submit multiple Web Forms simultaneously with JavaScript _javascript tips

Source: Internet
Author: User
1 questions from a netizen's question:
There are multiple forms in a Web page, and each form corresponds to a certain type of data operation.
For example, a detailed resume information page points
1. Personal Data
2. Working experience
3. Project Experience
4, other information 4 forms.
The general requirement is to allow the user to submit any one of the forms to the next page for modification (that is, the page has 4 different change buttons, which button to submit the data to the server only for one form, and according to the form's action).
Now there is this requirement that allows the user to select any one or more forms to submit changes, so how does the client submit the form?
Statement: Some people may say that the 4 form to synthesize a large form, depending on the different buttons to modify the server side of the different data operations can be. This is a solution, but considering the large amount of page data, in order to improve efficiency, reduce the amount of data transmission, or want to be able to be divided into multiple forms to submit, so this approach is not considered. Are you sure you want to use JS or Ajax? What if we don't?

2 person Opinion
1 Submit with Ajax, such as prototype
New Ajax.request ("/do1", {parameters:$ ("Form1"). Serialize () ...);

New Ajax.request ("/do2", {parameters:$ ("Form2"). Serialize () ...);

You can simultaneously invoke multiple, default asynchronous commits, so you can submit multiple forms at the same time, this scenario is the simplest.

2 use multiple iframe, then point target of each form to a different IFRAME
And then use the JS
document.getElementById ("Form1"). Submit ();
document.getElementById ("Form2"). Submit ();
。。。
Submit in this manner.


Comparison of 32 methods
Ajax convenient and simple, the processing of the result is also more convenient, the framework for us to do, but can not be committed across the domain
The IFRAME is most suitable for general use, can also be submitted across the domain, processing return results slightly more trouble, need to use parent in IFRAME. Make a call.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.