我正在使用角度发送http请求,如下所示。
$http({
url: url,
params: params,
method:'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
timeout: 60000 //60 seconds
}).success(function(data, status, headers, config) {
//do something
}).error(function(data, status, header, config) {
if(timedout){ //determine occurrence of timeout.
//invoke timeout handler
} else
//handle other error
}
});
如何确定超时?
我发现在这种情况下收到状态码“0”。超时检查状态== 0是否安全?
请注意,我不问HTTP请求超时(状态码408)。
我所知道的是'status === 0'确实没有**象征超时。它是服务器不使用时的代码'用正确的HTTP状态做出响应,或者不响应高。 – Blackhole
这也是呼叫中止时的状态。 – Francisc