jus*_*n.c 2 json odata angularjs
Angular和javascript的新手.我使用Angular连接到不同服务器上的服务.我能够很好地获取数据,但是当我试图发布时,我得到了404.我试图尽可能地遵循Angular文档.我究竟做错了什么?
PS.我已经嗅到了我的流量,我注意到我的POST十六进制是完全空的.我很难过.
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);
}]);
Run Code Online (Sandbox Code Playgroud)
它看起来像是服务器端配置上的东西.我们已将Access-Control-Allow-Origin设置为*.根据下面的答案,Chrome不再支持.
原(错):
header("Access-Control-Allow-Headers: *");
Run Code Online (Sandbox Code Playgroud)
更正:
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请查看此帖子. /sf/answers/1273489381/