火狐社区

标题: firefox页面跳转时有ajax请求暂未响应时,与chrome浏表现... [打印本页]

作者: htmlc    时间: 2021-10-13 11:31
标题: firefox页面跳转时有ajax请求暂未响应时,与chrome浏表现...
有这样一个场景,当我进入页面A时,会同时发送两个请求1和2。这两个请求都会返回我是否已经登陆的状态,当符合我的跳转逻辑时,我会window.location.href跳转,但是此时另一个请求还未返回。在谷歌上此场景的表现为:第二个接口会返回内容且是200。在火狐上此场景的表现为:axios走了catch,且code为ECONNABORTED。疑惑的是为什么会出现这样的场景,还请火狐相关的开发人员可以解答下。以下附上浏览器执行结果截图和代码图片:

以下是示例代码:

axios.post('http://localhost:4000/a').then((res) => {
            window.location.href = 'http://www.baidu.com' // 在a接口返回时就会调用跳转
            console.log('url被替换,但我仍然执行了。');
            console.log(axios);
        })
        axios.post('http://localhost:4000/b').then((res) => {
            console.log('success');
            console.dir(JSON.stringify(res));
        }).catch(e => {
            // debugger
            console.log(window.location.href);  
            console.log('error');
            console.dir(JSON.parse(JSON.stringify(e)));
        })







版本信息:
系统版本:windows10
chrome版本: 版本 94.0.4606.81(正式版本) (64 位
firefox版本:93.0 (64 位)
axios版本:axios v0.21.1





欢迎光临 火狐社区 (http://mozilla.com.cn/) Powered by Discuz! X3.1