title: Angularjs: Unexpected token g in JSON at position 0
body: <p>When I execute the method saveUser(),it shows the error, but the user can be saved into database. What's wrong?</p>
  
  <p>error info:</p>
  
  <blockquote>
    <p>angular1.5.3.min.js:116 SyntaxError: Unexpected token g in JSON at position 0
        at Object.parse (native)
        at uc (localhost:8080/js/angular1.5.3.min.js:17:6)
        at ac (//localhost:8080/js/angular1.5.3.min.js:90:253)
        at //localhost:8080/js/angular1.5.3.min.js:91:164
        at q (//localhost:8080/js/angular1.5.3.min.js:7:355)
        at ed (localhost:8080/js/angular1.5.3.min.js:91:146)
        at c (/localhost:8080/js/angular1.5.3.min.js:92:403)
        at localhost:8080/js/angular1.5.3.min.js:128:305
        at m.$eval (//localhost:8080/js/angular1.5.3.min.js:142:467)
        at m.$digest (//localhost:8080/js/angular1.5.3.min.js:140:47)(anonymous function) @ angular1.5.3.min.js:116(anonymous function) @ angular1.5.3.min.js:89(anonymous function) @ angular1.5.3.min.js:128$eval @ angular1.5.3.min.js:142$digest @ angular1.5.3.min.js:140$apply @ angular1.5.3.min.js:143g @ angular1.5.3.min.js:95x @ </p>
  </blockquote>
  
  <p>angular1.5.3.min.js:100v.onload @ angular1.5.3.min.js:101</p>
  
  <p>js file:</p>
  
  <pre><code>var app = angular.module('MyApp', ['ngResource']);
  
  
      app.factory('baseRequest', ["$resource", function ($resource) {
  
          return $resource("/apis/:id/users.req", {id: '@id'}, {
  
              query: {method: 'get', isArray: false}
          });
  
      }]);
  
  
      app.controller("MyCtrl", ["$scope", "baseRequest", function ($scope, baseRequest) {
  
  
          /**
           *   all
           *
           **/
  
          $scope.fetchAllUsers = function () {
  
              $scope.users = baseRequest.query();
          };
  
  
          /**
           *   first show
           *
           **/
  
          $scope.fetchAllUsers();
  
          /**
           *   delete
           *
           **/
  
          $scope.deleteUser = function (id, name) {
  
              if (confirm("delete[" + name + "]?")) {
  
                  baseRequest.delete({id: id});
                  $scope.fetchAllUsers();
  
              }
          };
  
          /**
           *   save
           *
           **/
          $scope.saveUser = function (u) {
  
              baseRequest.save(u);
              $scope.fetchAllUsers();
  
          };
  
      }]);
  </code></pre>
  
  <p>here is the jsp file:</p>
  
  <pre><code>&lt;div style="float: left;margin-left: 20px;width: 350px;"&gt;
  
      &lt;span&gt;UserName:&lt;/span&gt;&lt;input type="text" ng-model="user.name" required&gt;&lt;br&gt;
      &lt;span&gt;Password:&lt;/span&gt;&lt;input type="password" ng-model="user.password" required&gt;&lt;br&gt;
      &lt;span&gt;Email:&lt;/span&gt;&lt;input type="email" ng-model="user.email" required&gt;&lt;br&gt;
      &lt;input type="button" ng-click="saveUser(user)" value="save_data"&gt;&lt;br&gt;
      &lt;span&gt;user'content：{{user}}&lt;/span&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>