android - AngularJS HTTP 状态 -1

标签 android angularjs cordova http http-status-codes

我正在使用 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/

相关文章:

android - 在项目中使用 Realm 的 Google Play 64 位合规性

javascript - 如何在 Ng-repeat 中设置跨度值

javascript - 在ng-repeat angularjs中显示数组对象

javascript - 防止 Android Ionic App 在恢复时重新加载

javascript - 如何在 Phonegap/Cordova(iOS 和 Android)的谷歌地图中获得后退按钮

ios - Cordova SocialSharing 插件 - Facebook 回调错误

java - FFmpeg Javacv - 延迟问题

Android,操纵以前的 Activity

android - 拖放动态添加的编辑 TextView

javascript - $cordovaContacts 加载速度非常慢