Mahesh K
Mahesh K

Reputation: 1697

CORS issue while submitting data to google forms in angular

While submitting the data : Error Message : XMLHttpRequest cannot load https://docs.google.com/forms/d/xxxxxxxxxxxxx/formResponse. 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:8090' is therefore not allowed access. The response had HTTP status code 405.

    $scope.postDataToGoogle = function(){
    $http({
        method: 'POST',
        crossDomain: true,
        url: 'https://docs.google.com/forms/d/XXXXXXXXXXXXXXXXXXXXXXXX/formResponse',
        // dataType: "xml",
        data: tempData,
        }).success(function(data,status){
            //alert(data)
            console.log("Success");

        }).error(function(data,status) {
            console.log('Error:' + status);
        });

    }

Upvotes: 2

Views: 3001

Answers (2)

Rambabu.Botcha
Rambabu.Botcha

Reputation: 78

Its not about jquery or angular, CORS allows or disallow done by Back-end server. Google might not support this.(to access https://docs.google.com)

CORS (Cross-Domain Resource Sharing) allows you to more cleanly separate your front-end from your back-end.

CORS is a group of special response headers sent from the server that tell a browser whether or not to allow the request to go through

Access-Control-Allow-Origin: http://example.com.

Why does jQuery throw an error when I request external resources using an Appcache Manifest?

Upvotes: 1

santhu
santhu

Reputation: 13

I do have tried with angular still not able solve it, but with jQuery its works for me.

$.ajax({
            url: 'https://docs.google.com/forms/d/xxxxxxxxx',
            data: tempData,
            type: "POST",
            dataType: "xml",
            statusCode: {
                0: function () {
                    alert('error');

                },
                200: function () {
                    alert('Thank you for your valuable feedback');

                }
            }
        })

Upvotes: 1

Related Questions