本地json文件上的$http.get和$http.post之间有什么区别?

本地json文件上的$http.get和$http.post之间有什么区别?,json,post,get,Json,Post,Get,我正在构建一个简单的应用程序,它通过本地JSON文件(data/customers.JSON)更新客户结果。我一直在测试一个$get.http请求,它在我的本地服务器上运行得非常好: app.controller(“customersCtrl", function($scope, $http){ $http.get(“data/customers.json") .success(function(data){ $scope.recipients

我正在构建一个简单的应用程序,它通过本地JSON文件(data/customers.JSON)更新客户结果。我一直在测试一个$get.http请求,它在我的本地服务器上运行得非常好:

 app.controller(“customersCtrl", function($scope, $http){
      $http.get(“data/customers.json")
        .success(function(data){
          $scope.recipients = data;
            console.log(data);
        })
        .error(function(data){
          alert("shit");
        });
我创建了一个标准Jquery模式表单#add customer,通过hg模型将新客户输入JSON文件,例如:

          <input type="text" class="form-control" ng-model=“customer.Name"/>    
           ...
   <button type="button" class="btn btn-primary" ng-click=“addCustomer();">Add Customer</button>
问题是我现在得到了一个奇怪的答案 加载资源失败:服务器响应状态为404(未找到),尽管JSON文件明显在那里()


有什么我遗漏的吗?本地JSON文件的行为不应该像CRUD APi吗?

当您只向我们显示客户端代码时,很难说为什么您的服务器会以特定的方式响应。这很公平,但从理论上讲,本地JSON文件的行为不应该像本地计算机上的get和post一样吗?不一定。404是错误的,但是当你向静态文件发出POST请求时抛出405是有意义的。该死的。。。我仍然在黑暗中。将我的JSON文件放在现场会帮助您了解发生了什么吗?不会,因为(假设URL是正确的)问题是服务器配置,而不是文件的内容。我不明白你为什么要对静态文件发出POST请求。
$scope.addRecipient = function(){
          $http.post(“data/customers.json", $scope.customer)
            .then(function(){
              $("#add-customer").modal("hide");
              location.reload();
        });

}