Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/260.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
$http.get(index.php中my函数的url)在调用my slim php函数时返回404错误_Php_Angularjs_Routing_Slim - Fatal编程技术网

$http.get(index.php中my函数的url)在调用my slim php函数时返回404错误

$http.get(index.php中my函数的url)在调用my slim php函数时返回404错误,php,angularjs,routing,slim,Php,Angularjs,Routing,Slim,当我使用$http.get从使用Slim构建的后端API获取用户列表时,收到404响应 这是我要调用的AngularJS方法 function ListCtrl($scope, $http) { $http.get('api/getuser.php/getUser').success(function(data) { $scope.users = data; }); } 这是我的Slim路线,位于getuser.php: $app = new Slim(); $app-&g

当我使用
$http.get
从使用Slim构建的后端API获取用户列表时,收到404响应

这是我要调用的AngularJS方法

function ListCtrl($scope, $http) {
  $http.get('api/getuser.php/getUser').success(function(data) {
    $scope.users = data;
  });
}
这是我的Slim路线,位于
getuser.php

 $app = new Slim();
 $app->get('/getUser', 'getUser');
 $app->run();

 function getUser() {
     $sql = "select * FROM employees ORDER BY id";
     try {
        $db = getConnection();
        $stmt = $db->query($sql);   
        $wines = $stmt->fetchAll(PDO::FETCH_OBJ);
        $db = null;
        echo json_encode($wines);
         } catch(PDOException $e) {
            echo '{"error":{"text":"'. $e->getMessage() .'"}}'; 
        }
    }

感谢您提前回复:)

您不需要注册函数而不是字符串吗

尝试:


尝试更改<代码> $http.jSOP到<代码> $http.GET对不起,它实际上是给我404而不是JSONP,请考虑我上面的编辑:可能是因为您使用了相对地址吗?尝试使用绝对instead,因为它没有使用URL重写,并且在index.php下的其他模块中工作正常
$app->get('/getUser', getUser);