如何为$ http提供文件路径

时间:2014-03-04 08:33:52

标签: javascript php angularjs

'use strict';

foodMeApp.controller('SearchController', function($scope, $http) {
     $scope.url = '/server/api.php'; // The url of our search, some thing wrong here
             
        // The function that will be executed on button click (ng-click="search()")
        $scope.search = function() {
             
            // Create the http post request
            // the data holds the keywords
            // The request is a JSON request.
            $http.post($scope.url, { "data" : $scope.keywords}).
            success(function(data, status) {
               ...
            }).error(function(data, status) {
               ...   
            });
        };
});

这里有什么问题$ scope.url ='/ server / api.php';

附加了目录结构和错误,

enter image description here

浏览器错误: enter image description here

如果需要更多信息,请告诉我

2 个答案:

答案 0 :(得分:0)

我认为将您的server文件夹移至app目录将解决此问题;)

答案 1 :(得分:0)

  

我认为,您的服务器文件夹未定义,请参阅该文件夹中的一些通知符号

尝试

$scope.url = 'server/api.php'; 

或者,尝试

$scope.url = '../server/api.php';