如何处理使用 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');
}