Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.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
Json 在POST上获取404错误。Angular.js_Json_Angularjs_Odata - Fatal编程技术网

Json 在POST上获取404错误。Angular.js

Json 在POST上获取404错误。Angular.js,json,angularjs,odata,Json,Angularjs,Odata,Angular和javascript的新特性。我正在使用Angular连接到不同服务器上的服务。我能够很好地获取数据,但当我试图发布时,我得到了404。我试着尽可能地遵循角度文档。我做错了什么 顺便说一句,我嗅到了我的流量,我注意到我的帖子完全是空的。我被难住了 EDIT: Heres the error(s) I am getting in the console. OPTIONS http://url 404 (Not Found) angular.js:7997<br> OP

Angular和javascript的新特性。我正在使用Angular连接到不同服务器上的服务。我能够很好地获取数据,但当我试图发布时,我得到了404。我试着尽可能地遵循角度文档。我做错了什么

顺便说一句,我嗅到了我的流量,我注意到我的帖子完全是空的。我被难住了

EDIT: Heres the error(s) I am getting in the console.

OPTIONS http://url 404 (Not Found) angular.js:7997<br>
OPTIONS http://url Invalid HTTP status code 404 angular.js:7997<br>
XMLHttpRequest cannot load http://url. Invalid HTTP status code 404



app.controller('SendController', ['$scope', 'Request', function($scope, Request) {

    $scope.request = {
        // test data here
    };

    $scope.send = function() {
        Request.save($scope.request);
    };
}]);


app.factory('Request', ['$resource',
    function($resource) {
        return $resource(url);
    }]);
EDIT:这是我在控制台中遇到的错误。
选择权http://url 404(未找到)angular.js:7997
选择权http://url 无效的HTTP状态代码404.js:7997
无法加载XMLHttpRequesthttp://url. 无效的HTTP状态代码404 app.controller('SendController',['$scope','Request',函数($scope,Request){ $scope.request={ //这里有测试数据 }; $scope.send=函数(){ 保存($scope.Request); }; }]); app.factory('请求',['$resource', 职能(资源){ 返回$resource(url); }]);
它看起来像是服务器端配置的东西。我们已将访问控制允许原点设置为*。根据下面的答案,Chrome不再支持这一点

原件(错误):

更正:

header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
有关更多信息,请查看此帖子。

您还需要共享服务器端代码-404表示服务器找不到路由。嘿,Ed,谢谢您的回复。我没有访问服务器端代码的权限。如果有帮助的话,我可以使用Postman,并且可以很好地发布到我的url。
url
return$resource(url)未在任何地方定义,感谢您的回复Beterraba。它在我的应用程序中的全局变量中定义。我只是为了视觉效果把它缩短了。我可以确认它正在工作,因为当错误返回时,我可以在控制台中看到完整的url。您可以通过
curl
从该url获得响应?
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");