ElenaDBA ElenaDBA - 1 year ago 71
AngularJS Question

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,

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

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

Answer Source

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?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download