【问题标题】:How to redirect to the successs page upon successfull http post request in angular Javascript如何在 Angular Javascript 中成功的 http post 请求后重定向到成功页面
【发布时间】:2017-03-25 21:28:14
【问题描述】:

我正在学习如何在我最喜欢的 PHP 框架 (CodeIgniter) 旁边使用 angular javascript。我有一个登录部分,它对服务进行身份验证并使用 Angular js 获取响应。代码工作正常。见下面的sn-p

var login = angular.module('authenticationApp' , ['ngMaterial' , 'ngRoute']) ;

    login.controller('authenticationController', function ($scope, $http) {

        $scope.authenticate = function () {

            if ($scope.username == undefined || $scope.password == undefined) {
                $scope.login_error_message = "All form fields are required" ;

            } else {
                var url = get_base_url() + 'student/authentication/login?username=' + $scope.username + '&password=' + $scope.password ;

                $http.post(url).then(
                    function (response) {
                        console.log(response) ;
                        /*Here I handle success*/                           
                    }, function (response) {
                        $scope.login_error_message = "Service Error!. Response: " + response ;
                    }
                ) ;
            }
        } ;

我的问题是如何将该响应发送到 success.php 页面并重定向到成功页面。我可以使用重定向

 window.location.href = get_base_url() + 'administrator/authentication/dashboard' ;

我现在的挑战实际上是将响应发送到这个新位置。

提前致谢,如果需要,我准备提供更多详细信息

【问题讨论】:

    标签: javascript php angularjs codeigniter codeigniter-3


    【解决方案1】:

    折腾了很久,我还是决定用纯js。蹩脚但有效。

    【讨论】:

      猜你喜欢
      • 2017-12-27
      • 2016-10-15
      • 2013-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-17
      • 2015-04-08
      • 1970-01-01
      相关资源
      最近更新 更多