如何在Angular中处理跨源请求的404异常?

时间:2017-02-21 10:57:03

标签: angularjs rest

我在其他主机上有UI应用程序休息服务,当它不可用时,我无法正确显示错误。

在控制台中我有一个非常好的消息:

XMLHttpRequest cannot load https://myserver.net:30540/myservice. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost:8080' is therefore not allowed access. The response had HTTP status code 404.

但是在错误处理程序中我得到了这样一个对象:

{"data":null,"status":-1,"config":{...},"statusText":""}

所以我无法得到也没有错误信息,也没有状态。我该如何正确处理?

0 个答案:

没有答案