1

Is there a workaround to sending POST request cross-domain via Angular, besides using a proxy? Below request is refused, ie: OPTIONS , net::ERR_CONNECTION_REFUSED It's just form data I want to submit to friend's local server for school project.

$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!");
        });
    }

1 Answer 1

1

You don't need to configure AngularJS for CORS. Your friend's server needs to support CORS requests and probably whitelist your domain. This depends heavily on the HTTP server used.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.