How and when Web pages submit data to the background

Source: Internet
Author: User

1. Submit via Form

This is the most traditional way of submitting HTML support, you need to create a form, and then the form contains various types of form elements, there is a submit button to submit to the background by the Submit button, this way after the page will be refreshed.

2. Submit via web link

Can be in the link to the page to submit the parameters, when the user clicked the link, the browser initiates a link to the access, thus also the link with the parameters submitted to the background, this way after the page will be refreshed.

3. Submit via Ajax

JavaScript supports AJAX creation of HTTP requests by creating an AJAX request in an event handler for an HTML page element, carrying the required arguments in the URL parameter, and submitting it to the background, which will not be refreshed after the submission.

In the actual Web page, we will choose the appropriate submission method based on the need of actual user interaction.

1, if you need to use some form type user input, such as text box, radio box, drop-down box, then you can choose the 1th and 3rd way, if you want to submit after the page refresh to choose 1th type, if you do not want to submit after the page refresh to choose the 3rd type.

2, if you do not need form type input, then you can choose the 2nd and 3rd way, if you want to submit after the page refresh to choose 2nd, if you do not want to submit after the page refresh to choose the 3rd type.

What if there are multiple submit buttons in a form?
For example, the Submit button in a form points to a different processing page, so that because the form is defined at the time the Table data processing page has been determined, there is no way to simply put multiple submit buttons in the form to achieve the goal. This requires JavaScript.
First define a function:


<script language=javascript>
function query () {
Form.action= "query.php";
Form.submit ();}
function Update () {
Form.action= "update.php";
Form.submit ();}
</script>

By changing the Action property value of the form through JavaScript, you can implement the multi-commit button and the function is different, the code in the page is as follows:


<form name= "form" method= "POST" action= "#" >
<input type= "button" name= "Query" onclick= "query ()" value= "Query" >
<input type= "button" name= "Update" onclick= "Update ()" value= "Update" >
</form>

How and when Web pages submit data to the background

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.