title: angularjs $http success data parameter doesn't return the right object
body: <p>I am using $http to POST an angularjs variable, I do receive the JSON equivalent in servlet's doPost method. When I write a JSON in the response from the servlet, $http.success(data, status, header, config) is called. But when I assign 'data' to an angularjs variable, no value get's assigned to the variable. Tried using JSON.parse(data) but of no use. Following is the code snippet.</p>
  
  <p>AngularJS</p>
  
  <pre><code>$scope.result = {
      title: "",
      subject: "",
      summary: "",
      body: "",
      extra: ""
  };
  
  $http.post(url, JSON.stringify(obj)).
  success(function(data, status, headers, config){
          $scope.result = JSON.parse(data);
          console.log("data: " + data);
          console.log("status: " + status);
          console.log("headers: " + headers);
          console.log("config: " + config);
      })
      .error(function(data, status, headers, config){
          $scope.result = JSON.parse(data);
          console.log("data: " + data);
          console.log("status: " + status);
          console.log("headers: " + headers);
          console.log("config: " + config);
      });
  </code></pre>
  
  <p>Console output on receiving the response is as follows</p>
  
  <pre><code>data: [object Object]
  status: 200 
  headers: function (name) {
     if (!headersObj) headersObj =  parseHeaders(headers);
  
     if (name) {
        return headersObj[lowercase(name)] || null;
     }
  
     return headersObj;
    }
  config: [object Object]
  </code></pre>
  
  <p>Following is the code snippet from the servlet.</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
      {
          System.out.println("doPost called");
          response.getWriter().write("{"title":"Transaction Status","subject":"Congratulations!!","summary":"Successfully received your request, below is your Transaction ID","body":"5a85fc3b303d47dca6514b707442f2cd","extra":"Please save this transaction ID for future reference"}");
      }
  </code></pre>
  
  <p>I am not able to obtain the JSON sent from doPost() method in angularjs success function. Is it the correct way of doing it?
  Angularjs automatically converts the received JSON to javascript object type, so I must be able to assign 'data' straight to $scope.result.</p>
  
  <p>It will be great if someone can please point me in right direction.</p>