XMLHttpRequest LEVEL 2
The popularity of the XHR
object as a de facto standard led to the creation of official specifications from the W3C to govern its behavior. XMLHttpRequest Level 1 simply defined the already existing implementation details of the XHR
object. XMLHttpRequest Level 2 went on to evolve the XHR
object further. Not all browsers have implemented all parts of the Level 2 specification, but all browsers have implemented some of the functionality.
The FormData Type
The serialization of form data is frequently needed in modern web applications, and so the XMLHttpRequest Level 2 specification introduces the FormData
type. The FormData
type makes it easy to both serialize existing forms and create data in the same format as a form for easy transmission via XHR. The following creates a FormData
object and populates it with some data:
let data = new FormData();
data.append("name", "Nicholas");
The append()
method accepts two arguments, a key and a value...