Issue in close progress dialog

sometime my server response came and i tried to close progress dialog but it doesn’t close . and in the back alert dialog display.

code that i used

AllFunctions.displayLoading(this.loading).then(() => {
            try{
            this.service.rechargePrepaid(this.opratorCode,this.rechargeType,this.mobileNo,this.amount).map(res => res.text()).subscribe(
              data => {
                
                  this.resString = data;
                  this.resString = this.resString.substring(this.resString.indexOf("{"), this.resString.lastIndexOf("}") + 1);
                  this.jsonobject = JSON.parse(this.resString).MRRESP;
                  this.stcode = this.jsonobject.STCODE;
                  this.stmsg = this.jsonobject.STMSG;

                  ResponseString.setStcode(this.stcode);
                    if(this.stcode === '0')
                    {
                      AllFunctions.closeLoading(); 
                      AllFunctions.doAlert(this.stmsg,this.alertCtrl);
                      this.prepaidForm = this.fb.group({
                              radioControl: [""],
                              operator: [""],
                              mobileNo: [""],
                              amount:[""],
                              smspin:[""]
                            });
                    }
                    else{
                      AllFunctions.closeLoading(); 
                       AllFunctions.doAlert(this.stmsg,this.alertCtrl); 
                    }
                },
                err => AllFunctions.doAlert(Constants.error + '- 991',this.alertCtrl)
                );
                }catch(error)
                {
                  AllFunctions.closeLoading(); 
                  AllFunctions.doAlert(Constants.error + '- 992',this.alertCtrl)
                }  
            });

 static displayLoading(navController: LoadingController) : any{
      this.loadingCtrl = navController.create({
          content: "Please wait..."
      });
        return this.loadingCtrl.present();
      }

      static closeLoading() {
          this.loadingCtrl.dismiss();
      }
AllFunctions.closeLoading().then(() => {
  AllFunctions.doAlert(this.stmsg,this.alertCtrl); 
}

Make sure you have closed the loading before opening the alert

thankx for quick reply…i will try then i let you know what’s the result…