angularjs - I am getting this error- angular.js:14525 TypeError: $http.post(...).success is not a function -


i getting following error**(angular.js:14525 typeerror: $http.post(...).success not function atchildscope.bindingcode.$scope.submit (clientside.html:36) @ fn (eval @ compile (angular.js:15358), :4:138))** while executing piece of code. piece of code sending object asp.net webapi , after processing getting data back-

   $scope.submit = function () {                     if($scope.customer.customername.length==0)                     {                         alert("not proper data");                     }                     else                     {                         $http.post("http://localhost:59040/api/customer", $scope.customer).                             success(function (data) {                             $scope.customer = data;                         });                     }                 } 

i did same error in similar solution angular + asp.net-web-api. error related version of angular.

the "success" function deprecated @ angular version 1.6.2

in case correct sintax

   $scope.submit = function () {                 if($scope.customer.customername.length==0)                 {                     alert("not proper data");                 }                 else                 {                     $http({                         method: 'post',                         url: 'http://localhost:59040/api/customer'                     }).then(function successcallback(data) {                         $scope.customer = data;                     }, function errorcallback(response) {                         console.log(response);                     });                 }             } 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -