【发布时间】:2014-07-24 20:08:14
【问题描述】:
除了使用代理之外,是否有通过 Angular 跨域发送 POST 请求的解决方法?以下请求被拒绝,即: OPTIONS , net::ERR_CONNECTION_REFUSED 这只是我想提交给朋友的本地服务器用于学校项目的表单数据。
$scope.postJSON = function(){
var objJson = angular.toJson($scope.event);
console.log(angular.toJson($scope.event));
delete $http.defaults.headers.common['X-Requested-With'];
$http({
method: 'POST',
url: 'http://friendslocalserver.com',
data: objJson
}).success(function() {
console.log("POST Json object worked!");
}).error(function(){
console.log("POST Json object failed!");
});
}
【问题讨论】: