【发布时间】: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