Home > Web Front-end > JS Tutorial > body text

How to submit multiple web forms at the same time using Javascript_javascript skills

WBOY
Release: 2016-05-16 18:38:14
Original
976 people have browsed it
1 Question comes from a netizen:
There are multiple forms in the web page, and each form corresponds to a certain type of data operation.
For example, a detailed resume information page is divided into 4 forms:
1. Personal information
2. Work experience
3. Project experience
4. Other information.
The general requirement is to allow users to submit any one of the forms to the next page for modification operations (that is to say, the page has 4 different modification buttons, and which button is clicked will only submit the data of a certain form to the server, and According to the action of the form).
There is now a need to allow users to select any one or more forms to submit modifications. In this case, how to submit the form on the client side?
Disclaimer: Some people may say that four forms can be combined into one large form, and different data operations can be performed on the server side according to the different modification buttons. This is a solution, but considering that the amount of data on the page is relatively large, in order to improve efficiency and reduce the amount of data transmission, we still hope to be able to submit it into multiple forms, so this method will not be considered for the time being. Do I have to use js or ajax? What if it is not used?

2 Personal views
1 Use Ajax to submit, such as prototype
new Ajax.Request("/do1",{parameters:$("form1").serialize( ).....);

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

You can call multiple at the same time. The default is asynchronous submission, so multiple forms can be submitted at the same time. This solution is the simplest.

2 Use multiple iframes, and then point the target of each form to a different iframe
Then use js's
document.getElementById("form1").submit();
document .getElementById("form2").submit();
. . .
Submit like this.


3 Comparison of the two methods
Ajax is convenient and simple, and the processing of results is also easier. The framework has done it for us, but it cannot be submitted across domains
iframe is most suitable for general use and can also be submitted across domains. It is a little more troublesome to process the returned results. You need to use parent. in the iframe to make the call.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!