title: Unable to parse JSON with AngularJS
body: <p>I have just started with AngularJS and tried a very basic example. The webpage contains a button, on click of which I request a json from the server.
  But whenever, I click the button, the code executes the portion in the error function.</p>
  
  <p>HTML file</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;head&gt;
      &lt;title&gt; step 4&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body ng-app="step4App"&gt;
      &lt;div ng-controller="FriendsCtrl"&gt;
  
          &lt;button ng-click="loadFriends()"&gt;Load Friends&lt;/button&gt;
      &lt;/div&gt;
  
      &lt;script src="angular.min.js"&gt;&lt;/script&gt;
      &lt;script src="xml2json.js"&gt;&lt;/script&gt;
      &lt;script src = "step4.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>var app = angular.module("step4App",[]);
  
  app.controller("FriendsCtrl", function($scope,$http) {
      $scope.loadFriends = function(){
  
  
  
          $http({method:'GET',url:'http://localhost:8080/test.jsp', params:{name:"abc",no:"LBF1151638"}}).success(function(data) {
              $scope.friends = data;
              document.write('&lt;p&gt;two&lt;/p&gt;');
              document.write(data);
          }).error(function() {
  
              alert("error");
              });
              }
  
  });
  </code></pre>
  
  <p>The jsp page as of now is returning this json response.</p>
  
  <pre><code>{"response":{"numFound":0,"start":0,"docs":[]}}
  </code></pre>
  
  <p>But I am not able to understand, why it always executes the error function.</p>
  
  <p>I checked in the browser Console that a request is being made and a 47byte response is received (equal to the no of characters in the JSON). But it doesn't print the JSON.</p>