function wsHttpPost(url, callback, formData) { var xhr = new XMLHttpRequest(); xhr.open('POST', url, true); xhr.withCredentials = true; xhr.onload = function () {}; xhr.onreadystatechange = function () { if (this.readyState === 4 && this.status == 200) { callback(this); } }; xhr.upload.onprogress = function (event) { //TODO show the progress }; xhr.send(formData); }