Using the FormData interface
One of the new features added to XMLHttpRequest
Level 2 (http://www.w3.org/TR/XMLHttpRequest2/) is the FormData
object. This enables us to use a set of key-value pairs that can be sent using AJAX. The most common use is in sending binary files or any other large amount of data. In this recipe, we will create two scripts that will send FormData
, one with a plain JavaScript and the other with jQuery, as well as the server-side code to support it.
Getting ready
The server will be done in Nodejs using restify (http://mcavage.github.io/node-restify/). In order to install the dependencies, a package.json
file can be created where restify will be added.
How to do it...
- The server should be able to accept
HTTP POST
with type ...
Get HTML5 Data and Services Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.