I have a multiple file uploader but while it's uploading sometimes 1 out of 10 files doesn't make it and it returns a Failed to load resource: net::ERR_CONNECTION_RESET
in chrome console. I tried to catch it with the try-catch, but it acts as if no error occurred. What am I doing wrong?
var ajax = new XMLHttpRequest();
ajax.open("POST", "/multiFileUploadHandler.php");
try {
ajax.send(formdata);
} catch (err) {
alert('Error: '+err);
}
This is likely because it is async. Try catching this with an onerror event handler.
ajax.onerror = function(error) {
// handle error
};
edit: corrected syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With