获取有关POST 404错误。 Angular.js [英] Getting 404 error on POST. Angular.js
问题描述
新角和JavaScript。我使用角连接到服务在不同的服务器上。我能够得到的数据只是罚款,但是当我尝试后,我得到一个404。我试图尽可能地遵循角文档。我在做什么错了?
PS。我已经嗅到我的流量,我发现我的POST六角完全是空的。我难倒。
编辑:继承人的错误(S)我得到在控制台中。OPTIONS HTTP:// URL 404(未找到)angular.js:7997< BR>
OPTIONS HTTP:// URL无效HTTP状态code 404 angular.js:7997< BR>
XMLHtt prequest无法加载的http:// URL。无效的HTTP状态code 404app.controller('SendController',['$范围','请求'功能($范围,请求){ $ scope.request = {
//这里的测试数据
}; $ scope.send =功能(){
Request.save($ scope.request);
};
}]);
app.factory('请求',['$资源',
功能($资源){
返回$资源(URL);
}]);
它看起来就像是在服务器端配置的东西。我们已经建立了访问控制允许来源为*。根据下面的答案,Chrome浏览器不再支持。
原件(错误):
标题(访问控制允许信头:*);
修正:
标题(访问控制允许信头:产地,X-要求-着,内容类型,接受);
有关更多信息,请查看这篇文章。
<一href=\"http://stackoverflow.com/a/18192705/3010896\">http://stackoverflow.com/a/18192705/3010896
new to Angular and javascript. I am using Angular to connect to a service on a different server. I am able to get data just fine, but when I am trying to post, I get a 404. I tried to follow the Angular documentation as closely as possible. What am I doing wrong?
PS. I have sniffed my traffic, and I noticed that my POST hex was completely empty. I am stumped.
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);
}]);
It looks like it was something on the server side configuration. We had set the Access-Control-Allow-Origin to *. According to the answer below, Chrome no longer supports that.
Original (wrong):
header("Access-Control-Allow-Headers: *");
Corrected:
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
For more information check out this post. http://stackoverflow.com/a/18192705/3010896
这篇关于获取有关POST 404错误。 Angular.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!