Transfer Binary Data and Track Upload Progress with a New XMLHttpRequest Level 2 Ajax library, xhr2-lib
Join the DZone community and get the full member experience.
Join For FreeSo 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.
Published at DZone with permission of Phil Parsons, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments