nmd*_*mdr 5 javascript xmlhttprequest
如何处理使用XMLHttpRequest向服务器发出同步请求而服务器不可用的情况?
xmlhttp.open("POST","Page.aspx",false);
xmlhttp.send(null);
Run Code Online (Sandbox Code Playgroud)
现在,此方案导致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');
}
Run Code Online (Sandbox Code Playgroud)