Php 对Ajax post请求执行一个方法
我在angular中使用ajax执行post请求,如下所示:Php 对Ajax post请求执行一个方法,php,angularjs,methods,Php,Angularjs,Methods,我在angular中使用ajax执行post请求,如下所示: angular.module("gameApp").controller("firstPageCtrl", function($scope,$http) { $scope.doLogin = function() { $http.post("lib/test.php", {username: $scope.username, password: $scope.password}).success(functio
angular.module("gameApp").controller("firstPageCtrl", function($scope,$http) {
$scope.doLogin = function() {
$http.post("lib/test.php", {username: $scope.username, password: $scope.password}).success(function(data) {
console.log(data);
}).error(function(data) {
console.log(data);
});
};
});
如您所见,我引用lib/test.php作为URL,在这里处理数据。但是,我想引用test.php中的一个方法,并在该方法中处理数据。我该怎么做呢?Ajax只允许您指定URL 由服务器端代码将URL转换为您想要的内容
创建一个包含要调用的函数的新PHP脚本,然后调用它。使用该脚本的URL而不是test.php。所以我必须构建一个路由处理?就像Zend框架中的例子一样?这是一种方法。