Http://www.cnblogs.com/shizqiang/p/5984414.html
Overview: With the rise of HTML5, the front end more and more diverse, such as the submission of forms, now there are many ways to choose, the following summarizes the common form submission method.
1. The most basic form submission.
<! DOCTYPE html>
The above code is very simple, note that the OnSubmit property in the from form must have a return, otherwise it will be ineffective. The OnSubmit property is optional, if you need JS to do some simple validation of the form, then you can use this way to do, JS if the validation does not pass the return false, then the form is not committed.
<! DOCTYPE html>
Slightly modified above, the form element added the ID, removed the onsubmit, and a type of the submit input button was also removed, instead of adding a normal button outside the from.
This button click will trigger a section of JS, in this JS can do data validation, if the verification through, then through the JS submission form, form form the function of adding ID is for JS to get form elements become convenient.
The above two methods are the most basic way to submit a form, the actual work can be arbitrarily selected.
2.FormData form submission.
Next, we look at the submission of the form through HTML5 's Formdata, which is submitted asynchronously, and the address of the browser is not changed.
<! DOCTYPE html>This way of committing to the previous two, async is the biggest difference, so one of the benefits of uploading files asynchronously is very cool. Add an INPUT element of type file to the form, it can be uploaded directly, it is very convenient.
3. Use jquery to send the Formdata form.
<! DOCTYPE html>4. Send the binary file data directly.
<! DOCTYPE html>Server receives:
<?PHP$FP = fopen (' avatar.png ', ' WB '), $size = Fwrite ($fp, file_get_contents (' Php://input '));p rint ' success ';
Receives the binary data in a stream manner. Complete!!!
HTML Form Submission Summary