首页 > 解决方案 > ajax成功导航到另一个页面的Framework7不起作用

问题描述

所以我将 phonegap/framework7 用于我正在开发的应用程序

我有以下 ajax 调用,它工作得很好..

$.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.');
        }
});

不工作的部分是 app.router.navigate("/success/"); 部分。我在控制台中没有错误。如果从程序中的其他任何地方调用此函数确实有效,所以我不确定在 ajax 成功后如何处理重定向,任何帮助将不胜感激。

标签: ajaxphonegaphtml-framework-7

解决方案


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

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

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

composeView.router.navigate("/success/");

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


推荐阅读