JSFiddle - React, Tailwind, and code Playground
JavaScript
$.ajax({
xhr: function()
{
var xhr = new window.XMLHttpRequest();
//Upload progress
xhr.upload.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
//Do something with upload progress
console.log("up", percentComplete);
}
}, false);
//Download progress
xhr.addEventListener("progress", function(evt){
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
//Do something with download progress
console.log("down", percentComplete);
}else{
// the way jsFiddle's ajax echo service works the length
// is not computable, so just adding this here:
console.log("down", evt.loaded / 600000);
}
}, false);
return xhr;
},
type: 'POST',
url: "/echo/json/",
data: {json: JSON.stringify(new Array(100000))},
success: function(data){
console.log(arguments);
//Do something success-ish
}
});