firefox中angular2嵌套发送请求问题
发布日期:2021-05-08 10:59:54 浏览次数:8 分类:原创文章

本文共 1071 字,大约阅读时间需要 3 分钟。

项目中碰到一个问题,需要在一个异步请求A的响应中再发送一个异步请求B,chrome中一切ok,但是firefoxB总是发送失败,浏览器f12开发者模式下甚至没有看到发送的请求B。

伪码如下:

 this.httpAPI.A().then(          resp => {                       if (!resp.success) {                           this.alertService.warning(resp.error);                        return;                    }                    //异步请求                    this.httpAPI.B();                    //页面实现跳转                    windows.location.href=xxxxxx                }            ).catch(function () {                             });

后来经过鉴定,问题出在href中,我猜测B请求还未返回结果,当前页面跳转,后续结果返回,没有接收器了。修改的办法是等B请求返回后,再执行href

 this.httpAPI.A().then(          resp => {                       if (!resp.success) {                           this.alertService.warning(resp.error);                        return;                    }                    //异步请求                    this.httpAPI.B().then(                     {                        //页面实现跳转                    windows.location.href=xxxxxx				});                                 }            ).catch(function () {                             });
上一篇:angular2里forRoot的作用
下一篇:【Netty】shutdownGracefully初识(二)

发表评论

最新留言

感谢大佬
[***.8.128.20]2025年03月17日 19时14分51秒