如何处理使用 XMLHttpRequest 向服务器发出同步请求并且服务器不可用的情况?
xmlhttp.open("POST","Page.aspx",false);
xmlhttp.send(null);
现在这种情况会导致 JavaScript 错误: “系统找不到指定的资源”
最佳答案
好的,我通过在 xmlhttprequest.send 周围使用 try...catch 解决了这个问题
:
xmlhttp.open("POST","Page.aspx",false);
try
{
xmlhttp.send(null);
}
catch(e)
{
alert('there was a problem communicating with the server');
}
关于javascript - 问题 : XMLHttpRequest - handle server connection lost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/377231/