title: AngularJS error sending form data to server with $http.put()
body: <p>I have the following controller:</p>
  
  <pre><code>function EditCtrl($scope,$http,$routeParams,$location) {
      $scope.master = {};
      $scope.actviePath = null;
      $http.get("/employeeApp/assets/php/index.php/users/" + $routeParams.id).success(function (data) {
          $scope.users = data;
  
          $scope.user = {
              name: data.name,
              email: data.email,
              userName: data.userName,
              password: data.password,
              role: data.role,
              availability: data.availability,  
          };
      });
  
       $scope.update_user = function(user) {
  
      $http.put("/employeeApp/assets/php/index.php/users/"+$routeParams.id, user).success(function(){
        $scope.reset();
        $scope.activePath = $location.path('/');
      });
      $scope.reset = function() {
        $scope.user = angular.copy($scope.master);
      };
      $scope.reset();
      };
  }
  </code></pre>
  
  <p>and the following html template:</p>
  
  <pre><code>&lt;div ng-init="$root.title='Add new user'"&gt;
      &lt;h2&gt;Edit user: &lt;/h2&gt;
      &lt;form novalidate name="AddNewForm" id="add-new-form" method="post" action=""&gt;
          &lt;label for="name"&gt;Name:&lt;/label&gt;
          &lt;input type="text" ng-model="user.name" /&gt;
          &lt;label for="email"&gt;Email:&lt;/label&gt;
          &lt;input type="email" ng-model="user.email" /&gt;
          &lt;label for="username"&gt;Username:&lt;/label&gt;
          &lt;input type="text" ng-model="user.userName" /&gt;
          &lt;label for="password"&gt;Password:&lt;/label&gt;
          &lt;input type="password" ng-model="user.password" /&gt;
          &lt;label for="role"&gt;User Role:&lt;/label&gt;
          &lt;input type="text" ng-model="user.role" /&gt;
          &lt;label for="availability"&gt;Availability: &lt;/label&gt;
          &lt;input type="text" ng-model="user.availability" /&gt;
          &lt;!--&lt;input type="hidden" ng-model="user.id" /&gt;--&gt;
          &lt;br /&gt;
          &lt;button class="btn btn-primary"  id="add-new-btn" ng-click="update_user(user)"&gt;Save!&lt;/button&gt;
          &lt;a href="#/" class="btn"&gt;Cancel&lt;/a&gt;
  
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When I try to edit a user and then save the change the following error appears in console and the form data is not sent to the server:</p>
  
  <pre><code>SyntaxError: Unexpected token S
      at Object.parse (native)
      at fromJson (angularjs/1.2.6/angular.js:1035:14)
      at $HttpProvider.defaults.defaults.transformResponse (angularjs/1.2.6/angular.js:6926:18)
      at angularjs/1.2.6/angular.js:6901:12
      at Array.forEach (native)
      at forEach angularjs/1.2.6/angular.js:302:11)
      at transformData angularjs/1.2.6/angular.js:6900:3)
      at transformResponse (angularjs/1.2.6/angular.js:7570:17)
      at wrappedCallback (angularjs/1.2.6/angular.js:10905:81)
      at angularjs/1.2.6/angular.js:10991:26 angular.js:9383
  (anonymous function) angular.js:9383
  (anonymous function) angular.js:6825
  wrappedCallback angular.js:10908
  (anonymous function) angular.js:10991
  Scope.$eval angular.js:11906
  Scope.$digest angular.js:11734
  Scope.$apply angular.js:12012
  done angular.js:7818
  completeRequest angular.js:7991
  xhr.onreadystatechange
  </code></pre>
  
  <p>On server I have a php API made with slim. The link to the server is app/index.php/user/suerId. 
  When I try to output {{user}} it displays data correctly, but I Don't know why I can't sent the data to the server.
  I am using angularjs 1.2.6. Does anyone knows why this is happening?
  Thnx in advance!</p>