AngularJS报错No 'Access-Control-Allow-Origin' header
2016-06-28 16:44
519 查看
报错:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access. The response had HTTP
status code 403.
解决方式:
angular.module('com.budee.award').controller('formController', function ($scope,$http) {
$scope.formData = {};
$scope.processForm = function () {
console.log("测试一下"+$scope.formData);
$http({
url:'http://1.iyyren.com/api/prize/111/record/save',
method:"POST",
<strong><span style="color:#ff0000;">headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},</span></strong>
data: $scope.formData
})
}
});
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access. The response had HTTP
status code 403.
解决方式:
angular.module('com.budee.award').controller('formController', function ($scope,$http) {
$scope.formData = {};
$scope.processForm = function () {
console.log("测试一下"+$scope.formData);
$http({
url:'http://1.iyyren.com/api/prize/111/record/save',
method:"POST",
<strong><span style="color:#ff0000;">headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},</span></strong>
data: $scope.formData
})
}
});
相关文章推荐
- Angularjs 指令示例
- AngularJS 指令实践指南
- Echarts图表在实际项目中的应用说明
- 【Web前端 - AngularJs】$location.path改变路径需要点击两次后才会跳转
- Num61 (angularjs路由,management页面搭建,spring data jpa)
- AngularJS中ng-repeat对象的问题
- angularjs 权威指南 版本 1.2.6
- angularJs模糊查询
- AngularJS directive指令
- Angularjs 跨域请求
- ng-class几种写法
- angular 插件angular-hint
- angularjs+requlirejs 搭建前端框架(1)
- Angular2开发笔记
- angularJS事件指令
- AngularJS常用插件与指令收集
- 带你初识Angular中MVC模型
- 《AngularJS权威教程》
- Angular2 (One framework 概要)
- AngularJS表单验证开发案例