admin管理员组文章数量:1356346
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.
本文标签:
版权声明:本文标题:xmlhttprequest - Javascript try-catch doesn't catch 'Failed to load resource: net::ERR_CONNECTION_RESET ' 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744015957a2576333.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论