Having a weird issue with onprogress for my XMLHttprequest.
I'm using the following code to log the response onprogress:
xhr.addEventListener("progress", function(event) {
target = (event.currentTarget) ? event.currentTarget : event.srcElement;
console.log('response: ',target.response);
}, false);
If i console.log just target
, I get an object, where I can see that response has text like so:
But if I try and log target.response
or target.responseText
, it is completely empty. No errors or even a length on the string.
Pretty sure it has something to do with the response being JSON, but I'm not sure where to start. Any ideas?