admin管理员组文章数量:1530043
测试时间:2019/02/26
MacOS 环境下,timeout在各浏览器默认值为(以下浏览器都为当前时间最新版本)
chrome 72.x 为4min
safari 12 为8min
firefox 65 貌似没有超时时间
测试代码
Documentquery
const ajax = (url = '/api/timeout') => {
const xhr = new XMLHttpRequest();
//设置xhr请求的超时时间
xhr.timeout = 60 * 5 * 1000;
xhr.responseType = "text";
xhr.open('GET', url, true);
xhr.onload = function(e) {
if(this.status == 200 || this.status == 304){
console.log('请求完毕')
if(loopId) {
clearInterval(loopId)
}
}
console.log(e)
}
xhr.send()
}
const queryBtn = document.querySelector('#queryBtn')
const time = document.querySelector('#time')
loopId = null
queryBtn.addEventListener('click', (event) => {
ajax()
const startTime = new Date()
loopId = setInterval(() => {
const s = parseInt((new Date() - startTime) / 1000)
time.innerHTML = s + ' s'
}, 500)
})
var express = require('express');
var app = express();
var http = require('http').Server(app);
var bodyParser = require('body-parser');
app.use(bodyParser());
app.use(express.json());
app.use(express.static(__dirname + ''));
app.get('/', function(req, res){
res.render('index', {});
// res.send('
Welcome Realtime Server
');});
app.get('/api/timeout', function(req, res){
setTimeout(() => {
res.send("i don't see a lot of PUT requests anymore")
}, 60 * 10 * 1000)// 这里设置服务器的响应时间
});
http.listen(3004, function(){
console.log('http://127.0.0.1:3004');
});
且在chrome设置timeout为5min没有用,在4min时已经提示请求失败
上面这张是chrome,下面是Safari
版权声明:本文标题:ajax默认超时时间多久,请问chrome浏览器的默认超时时间是多久? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1726735604a1082672.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论