HTML5 FormData Simulation Form control supports asynchronous upload of binary files on the mobile side

Source: Internet
Author: User

Formdata is a new interface added by XMLHttpRequest Level 2, using the Formdata object, we can use JavaScript to simulate a series of form controls with some key-value pairs, as well as using XMLHttpRequest's Send ( ) method to commit the "form" asynchronously. The biggest advantage of using formdata compared to normal Ajax is that we can upload a binary file asynchronously.

Mainstream mobile phone system is basically webkit core, can be used.

var form= new FormData (optional htmlformelement from);//can accept one-piece form element note

You can enter Console.dir (form) in the Google console panel to see how the form looks:

1, append (): Add data for key-value pairs.

2. Delete (): Deletes the data to be deleted based on the key value name.

3, Entries (): Traversal of key-value pairs, ES2016 syntax, usage: Form.entries.next () returns a key-value pair of a map data structure, directly returning a iterator object with Form.entries ().

4. ForEach (): Use the callback function to traverse each member.

5, Get (): Get value by key value

6, GetAll ():

7, has (): The key value to determine whether to use the data

8. Keys (): The iterator that returns the key name

9. Set (): Set new value

10. VALUES (): Iterator of the return value of the Walker

Form.append (Key,value);//Add key value pair data if a form has been passed in, the Name property of the HTML is key such as <imput name= "user" > key value pair is the value of name "user"

Form.get ("user"), or//based on the name attribute of the HTML, also known as key to obtain

HTML5 FormData Simulation Form control supports asynchronous upload of binary files on the mobile side

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.