我正在使用 cordova(Android 和 iOS)处理 angularjs 应用程序的离线处理。我写了一个 http 拦截器,它检查 http 请求的状态,并决定做什么。
一个月前我有一个工作版本,突然间它停止工作了。我发现我正在检查 0
的 http 状态。现在返回 -1
,但我不知道为什么。
responseError: function(response) {
console.log(response.status); // this returns now -1
}
所以我的问题是:
- What are the standard http codes for ajax requests that define cases like network unavailable, offline, timeout... everything when the server is not reachable (e.g. when you shut down your server in development, your mobile connection breaks, or is too slow and times out...)
- Is the status code set by the browser, or manipulated by AngularJS?
- Are this codes the same across every browser? Desktop & mobile?
- What is the difference between code
0
and-1
?
最佳答案
angular 的最新版本发生了变化,处理了 http 状态代码 0。 Here is a github discussion based on the change.
我希望你现在已经解决了你的问题!
关于android - AngularJS HTTP 状态 -1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34022221/