title: AngularJS : TypeError: $http(...).success is not a function on asp.net WebMethod
body: <p>I am new to <code>AngularJs</code> and using it in a web form</p>
  
  <p>My Code is as below</p>
  
  <pre><code>var app = angular.module('demoApp', [])
  app.controller('usrController', function ($scope, $http, $window) {
      $scope.userdata = {};
      var post = $http({
          method: "POST",
          url: "Index.aspx/GetData",
          dataType: 'json',
          data: {},
          headers: { "Content-Type": "application/json" }
      }).success(function (data, status) {
          console.log(data);
          $scope.userdata = data.d;
      }).error(function (data, status) {
          $window.alert(data.Message);
      });
  });
  </code></pre>
  
  <p>My WebMethod code is as below</p>
  
  <pre><code>[WebMethod]
  public static string GetData()
  {
      DataTable dt = Helper.UserList("sp_GetSearchList");
      string JSONString = string.Empty;
      JSONString = JsonConvert.SerializeObject(dt).ToString();
      return JSONString;
  }
  </code></pre>
  
  <p>My JSONString returns perfect json but I got error as</p>
  
  <blockquote>
    <p>TypeError: $http(...).success is not a function</p>
  </blockquote>
  
  <p>I have seen a lot of answers on Stack overflow but none of them actually solved this.</p>
  
  <h2>Extended Question</h2>
  
  <p>After using the following code it solved my question</p>
  
  <pre><code>var app = angular.module('demoApp', [])
  app.controller('usrController', function ($scope, $http, $window) {
      $scope.userdata = {};
      $http.post("Index.aspx/GetData", {}).
      then(function (response) {
          console.log(JSON.parse(response.data.d));
          $scope.userdata = JSON.parse(response.data.d);
      });
  }, 
  function(error) {
  
  });
  </code></pre>
  
  <p>My front end binding is this</p>
  
  <pre><code>&lt;body data-ng-app="demoApp"&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;div data-ng-controller="usrController"&gt;
               &lt;table&gt;
                   &lt;tr&gt;
                       &lt;th&gt;Sl No&lt;/th&gt;
                       &lt;th&gt;User ID&lt;/th&gt;
                       &lt;th&gt;Employee ID&lt;/th&gt;
                       &lt;th&gt;Employee Name&lt;/th&gt;
                       &lt;th&gt;Birth Date&lt;/th&gt;
                   &lt;/tr&gt;
                   &lt;tr data-ng-repeat="data in userdata"&gt;
                      &lt;td&gt;{{data.ID}}&lt;/td&gt;
                      &lt;td&gt;{{data.UserID}}&lt;/td&gt;
                      &lt;td&gt;{{data.EmployeeID}}&lt;/td&gt;
                      &lt;td&gt;{{data.EmpName}}&lt;/td&gt;
                      &lt;td&gt;{{data.BirthDate}}&lt;/td&gt;
                   &lt;/tr&gt;
               &lt;/table&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>The data comes perfectly in <code>console.log</code> but its not binding in front end.</p>
  
  <p>Help me where I am wrong.Thanks in advance</p>