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);
}
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);
}
Share
Improve this question
asked Mar 5, 2014 at 10:35
Matthew AbrmanMatthew Abrman
73110 silver badges18 bronze badges
1
- usually this error happens when the server's transport detected a error condition and thus it does reset your TCP/IP connection ! :) – Mehdi Maghrouni Commented Mar 26, 2014 at 16:43
1 Answer
Reset to default 6This is likely because it is async. Try catching this with an onerror event handler.
ajax.onerror = function(error) {
// handle error
};
edit: corrected syntax.