Home > front end >  JavaScript form submission
JavaScript form submission

Time:12-27

//form form the properties of the action and method
/*
The attribute value description
The action URL rules when submitting the form where to send the form data
Method get/post rules used to send the form to the data of the HTTP method, (submission form)


URL possible values:
Absolute URL - pointing to other sites (such as SRC="https://bbs.csdn.net/topics/www.baidu.com")
Relative URL - pointing at the site files (such as SRC="https://bbs.csdn.net/Form00/getData")
*/
//the value of the method get/post
/*
Get submitted directly exposed to the URL parameters,
(W3School given on difference:)
Compared with the POST, GET more simple and faster, and in most cases are available,
However, in the following cases, please use the POST request:
1. Unable to use the cache file (update the file on the server or database)
2. Huge amounts of data can be sent to the server (POST there is no limit to the amount of data)
3. Send contains unknown character of user input, POST than GET more stable and more reliable
Get/post difference:
1. The GET method is used to GET the data to the server, and PSOT is used to transfer modify data on the server,
2. GET the data in a form is added to the action points to the URL, and between the use of "?"
Between each variable and the use of "& amp;" The connection; PSOT is the form of the data in the form of data volume (FormData),
According to the keys on the way, is passed to the points of action
3. It is not safe to GET, because in the process of transmission, data is placed on the requested url so that users can directly see the data submitted on the browser,
POST all the operations are not visible to the user, the data in data volume (FormData)
4. The GET method to the URL to add data, the length of the URL is restricted maximum length is 2048 characters (URL), POST submission unlimited
https://www.w3school.com.cn/tags/html_ref_httpmethods.asp
5. GET to the default submission form form
6. The GET method to GET the data after the refresh will not have a negative impact, because it is just to GET the data,
POST data will be resubmitted may have adverse consequences (browser should inform the user data will be resubmitted)
7. The data type of restrictions: GET allow only ASCII characters, the POST is unrestricted (if submitted binary data (such as picture), you need to use the POST method)
  • Related