Coding Duchess
Coding Duchess

Reputation: 6919

AngularJS posting data to DB - data gets entered but error is shown

I am inserting data into the database from AngularJS application. I create a data object and fill it with data then call post request. I get an error Failed to load resource: the server responded with a status of 500 (Internal Server Error) but meanwhile the data does get entered into the database. Not sure why this is happening and what is going on

 var inputData = {
            "EntryDate": $filter('date')(curdate, 'yyyy/MM/dd hh:mm:ss'),
            "Field1": $scope.$parent.field1,
            "Field2": $scope.$parent.field2,               
            "SortOrder":1
        };


 var config = {
                method: "POST",
                url: window.baseApiUrl + '/PostEntry',
                data: inputData
            };  

        $http(config).
            then(function (data, status, header) {
                $scope.result = "Success"
               console.log($scope.result);
            }, function errorCallback(xhr) {
                //print error to console.
                console.log(header.responseText);
                $scope.result = header.responseText;
            });

Upvotes: 0

Views: 28

Answers (1)

fmello
fmello

Reputation: 563

Do you have access to the server code? Any chance it is erroring while executing an operatoon after the "write to DB" action is done? Maybe while formatting the response?

Upvotes: 3

Related Questions