ajax默认超时时间多久,请问chrome浏览器的默认超时时间是多久?

测试时间:2019/02/26

MacOS 环境下,timeout在各浏览器默认值为(以下浏览器都为当前时间最新版本)

chrome 72.x 为4min

safari 12 为8min

firefox 65 貌似没有超时时间

测试代码

Document

query

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

bVboUeX?w=1794&h=1042

bVboUkv?w=2104&h=774

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值