Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Transfer Binary Data and Track Upload Progress with a New XMLHttpRequest Level 2 Ajax library, xhr2-lib

DZone's Guide to

Transfer Binary Data and Track Upload Progress with a New XMLHttpRequest Level 2 Ajax library, xhr2-lib

· Web Dev Zone ·
Free Resource

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

So a while ago a messed about with the File API and FormData with the XMLHttpRequest Level 2 spec which enables the transfer of binary data and tracking of the upload progress through the XMLHttpRequestUpload object – awesome. I was blown away when I first started messing about with this stuff and support for it now seems to be a little more wide spread, nothing in IE or Opera as of yet but you know life goes on. What I did start to do was abstract some of the code I was messing about with into a little module aptly named xhr2-lib which I’ve grown a bit since and would like to share and hopefully get some feedback.

This micro library follows the example of the jQuery Ajax api with many of the same function names, I’m not suggesting it is anywhere near as comprehensive but I wanted a familiar set of tools to work with. I have put in the short cut methods like .getJSON and .post and am at the stage now of fleshing out the core and adding some tests and examples. Please check out the code and documentation on Github for now and I will add some demos here over the coming couple of weeks.

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}