0

我正在为我的应用程序使用 Revel + angular。index页面是登录界面,成功后应该会跳转到dashboard.html页面。问题是,一旦我发出 POST 请求,我就会收到一个带有“响应正文”的 GET 请求,但是,我仍然在登录页面中。我正在使用 Angular 向我的宁静服务器发出发布请求。但是,每当我发出 POST 请求时,我的 POST 请求都会得到状态 302,但我的 GET 请求会获取页面的响应。

我的角度控制器

appMainLogin.controller('MainLoginForm',function($scope, $http){

    $scope.user_email = null;
    $scope.user_pass = null;
    $scope.user_remember = true;

    $scope.userLogin = function () {

        var val = {
            "user_email": $scope.user_email,
            "user_pass": $scope.user_pass,
            "user_remember": $scope.user_remember,
            };
        var stringify = JSON.stringify(val);

    $http({
        url: '/login',
        method: 'POST',
        data: stringify || '',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
        }
    }).success($scope.getEmailData).error($scope.httpError);
            alert("error");
    };
});

我的路线

POST /login App.Login
GET  /dash  Dash.Index

我得到这个: POST 请求上的 302 我得到这个: GET 请求上的 200 OK 在 GET 请求(firefox 调试器)的“响应正文”上,我看到了我想要的 html 页面,但我仍然保留在索引页面中。

为什么我的应用程序在用户输入他们的登录凭据(基于我上面的代码)后没有重定向到dashboard.html(index.html->dashboard.html)?

4

0 回答 0