var _xhr2 = new XMLHttpRequest();
_xhr2.upload.addEventListener('progress', function(e){ //#1
console.log('progress');
}, false);
_xhr2.upload.onprogress = function(e){ //#2
console.log('progress');
};
_xhr2.open('POST', '/fileupload');
_xhr2.send(formData);
Could someone explain the difference between #1
and #2
above. Which one is preferred over the other? Because both seems to work.
The reason that I'm asking is because I'm playing around a bit with the HTML5 filereader + XHR2 upload, and in the MDN examples instances of FileReader()
uses #2
, while XMLHttpRequest()
uses #1
.