这是在Safari浏览器的iOS 10科尔多瓦发生:6.3.1
请求采用了棱角分明的$ HTTP,误差函数不叫
$http.get("http://10.255.255.1").then(function(res){
console.log("res: " + res);
},function(err){
console.log("err: " + err);
});
Promise {$$state: {status: 0}, then: function, catch: function, finally: function}
控制台:加载资源失败:请求超时。 (10.255.255.1,线0)使用的XMLHttpRequest
请求捕捉超时错误
var xhr = new XMLHttpRequest(); xhr.onload = function() {
console.log("request finished")
};
xhr.ontimeout = function (e) {
console.log("request timeout")
};
xhr.open('GET', 'http://10.255.255.1', true);
xhr.send(null);
控制台:请求超时
供参考: http://10.255.255.1是,我使用到一个URL测试超时。 来源:Artificially create a connection timeout error
仅供参考:已在Angular中修复此问题,修复程序将包含在版本1.5.9和1.6.0-rc.0中。另见https://github.com/angular/angular.js/issues/15380。 – gkalpak