Framework7 on ajax success navigating to another page is not working

时间:2018-09-18 20:34:25

标签: ajax phonegap html-framework-7

So i'm using phonegap/framework7 for an app i'm working on

i have the following ajax call which works just fine..

$.ajax({
        method: "POST",
        url: myApi+ "ratings",
        data: ratingForm,
        success: function() {

            //works fine
            alert("test success");

            //this part doesn't work!
            app.router.navigate("/success/");

        },
        error: function () {
            app.dialog.alert('We apologize, an error 
occurred while trying to saving your rating.  Please try 
again.');
        }
});

The part not working is the app.router.navigate("/success/"); part. I have no errors in the console. This function DOES work if called from anywhere else in the program, so i'm not sure how to handle redirecting after an ajax success, any help would be much appreciated.

2 个答案:

答案 0 :(得分:0)

我认为您应该使用:

app.mainView.router.navigate('/success');

缺少的部分是 mainView

答案 1 :(得分:0)

经过大量的游戏,我终于开始工作了... 我正在使用选项卡式布局,在app.js中有以下内容

var composeView = app.views.create('#view-compose',{   网址:“ / compose /” });

在我的ajax成功上,我现在正在做...

composeView.router.navigate(“ / success /”);

并且路由正确,谢谢所有提供帮助的人!