How to submit multiple web forms simultaneously using JavaScript

Source: Internet
Author: User

1. question from a netizen:
There are multiple forms in the web page. Each form corresponds to a type of data operation.
For example, a detailed resume information page is divided
1. Personal Data
2. Work Experience
3. Project Experience
4. Other information 4 forms.
Generally, users are allowed to submit any form separately to the next page for modification (that is, the page has four different modification buttons, click the button to submit only the data of a form to the server and follow the action of the form ).
You can select any one or more forms to submit and modify. In this case, how can you submit a form on the client?
Declaration: it may be said that four forms are merged into a large form, and different data operations can be performed on the server based on the modification button. This is a solution, but considering that the page data volume is large, we still want to split it into multiple forms for submission to improve efficiency and reduce the data transmission volume. Is it necessary to use JS or Ajax? What if not?

2 Views
1. Submit with Ajax, for example, prototype
New Ajax. Request ("/do1", {parameters: $ ("form1"). serialize ().......);

New Ajax. Request ("/do2", {parameters: $ ("form2"). serialize ().......);

You can call multiple forms at the same time. By default, multiple forms can be submitted asynchronously. This solution is the simplest.

2. Use multiple IFRAME and point the target of each form to a different IFRAME.
Then
Document. getelementbyid ("form1"). Submit ();
Document. getelementbyid ("form2"). Submit ();
...
Submit in this way.

3 comparison of the two methods
Ajax is convenient and simple, and the processing of results is easier. The framework is ready for us, but cross-origin submission is not allowed.
IFRAME is most suitable for common use, and can also be submitted across domains. It is a little troublesome to process the returned results. You need to use parent. in IFRAME for calling.

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.