AngularJS报错No 'Access-Control-Allow-Origin' header

报错:

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",
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            data: $scope.formData
        })
    }
});




你可能感兴趣的:(AngularJS报错No 'Access-Control-Allow-Origin' header)