2016-12-23 4 views
1

私は決済モードを開き、一度ユーザーが記入すると支払いが成功すれば、別のページにリダイレクトして成功したいメッセージ。私はLaravel 5.3とVue JSを使っています。お支払い後に別のページにリダイレクトする - Vue JS

今のところ、このように見えますが、別のページにリダイレクトするようになっていますが、どのように成功メッセージを添付すればよいですか?

this.$http.post('/cropkit/public/subscriptions', this.$data).then(
    window.location.replace('/cropkit/public/profile/dashboard'), 
    response => this.status = response.body.status 
); 

/******** EDIT *********/

ここ

が成功するかどうかをチェックするためのソリューションである、またはエラーが発生しました:

swal警告メッセージプラグインです

    this.$http.post('/mysite/subscriptions', this.$data).then((response) => { 
         swal({ 
          title: "Success!", 
          text: "Payment has been processed!", 
          type: "success", 
          showConfirmButton: false, 
          allowEscapeKey: false, 
          allowOutsideClick: false, 
          timer: 5000, 
         }), 
         setTimeout(function(){ 
          window.location.replace('/mysite/profile/dashboard'); 
         }, 4000) 
        }, (response) => { 
         this.status = response.body.status 
        }); 

答えて

1

エラーコールバックを使用できます。

return this.$http.post(url, data).then((response) => { 
    // success, do success logic 
}, (response) => { 
    // redirect to error view 
}); 
+0

はい、ありがとうございました。上に編集されたソリューション – David

関連する問題