I am using XHR to upload a file which works great in FF but fails in Chrome.
An error is thrown which says Upload failed: 0 which means that xhr.status comes back as 0 - I'm not sure what this means? No other status is recorded.
//Check if we have XHR / File support
if (typeof File != "undefined" && typeof (new XMLHttpRequest()).upload != "undefined")
{
var xhr = new XMLHttpRequest();
xhr.upload.onprogress = function(e){
if (e.lengthComputable){
uploadStarted = true;
var loaded = (e.loaded / e.total) * 100;
ShowProgress(loaded);
}
};
xhr.onreadystatechange = function(){
if (xhr.readyState == 4){
if (xhr.status == 200){
uploadComplete();
} else {
alert("Upload failed: " + xhr.status);
}
console.log("status",xhr.status);
}
};
var formElement = document.getElementById("configForm");
xhr.open("POST", $("#configForm").attr('action') , true);
xhr.send(new FormData(formElement));
}