title: Unexpected token in JSON at position 39
body: <p>I have a php api for a dictionary web app, </p>
  
  <pre><code>$outp = "";
  
  while($rs = $result-&gt;fetch_array(MYSQLI_ASSOC)) {
      if ($outp != "") {$outp .= ",";}
      $outp .= '{"WORD":"'  . $rs["word"] . '",';
      $outp .= '"MEANING":"'   . $rs["definition"]        . '"}';
  }
  $outp ='{"records":['.$outp.']}';
  $conn-&gt;close();
  
  echo($outp);
  
  }
  else
  {
  
  
  }
  ?&gt;
  </code></pre>
  
  <p>and at the angularJS side the parsing function is as follows : </p>
  
  <pre><code>$scope.counter = function() {
                      console.log(JSON.stringify(response));
  
      if($scope.name) {
          $http.get("http://localhost/dictionary/API/search.php?qr="+$scope.name)
              .then(function (response) {
                  console.log(JSON.stringify(response.records));
              if(response.data.records=="") {
                  queryRes = response.data.records ;
                  $scope.word = "";
                  $scope.meaning = ""
              } else {
  
                  queryRes = response.data.records ;
                  $scope.word = queryRes[0].WORD;
                  $scope.meaning = queryRes[0].MEANING;
              }
  
      });
  
      }
  
  }
  </code></pre>
  
  <p>there is no error when the php api returns single element array JSON like this</p>
  
  <pre><code>{"records":[{"WORD":"Net","MEANING":"വല"}]}
  </code></pre>
  
  <p>But when php returns array of multiple elements like , </p>
  
  <pre><code>{"records":[{"WORD": "End","MEANING": "അറുതി
  "},{"WORD": "End","MEANING": "അവസാനം
  "},{"WORD": "End","MEANING": "അതിര്‌
  "},{"WORD": "End","MEANING": "സീമ
  "},{"WORD": "End","MEANING": "പരിസമാപ്‌തി
  "},{"WORD": "End","MEANING": "അവസാനഘട്ടം
  "},{"WORD": "End","MEANING": "മരണം
  "}]}
  </code></pre>
  
  <p>Getting error like this </p>
  
  <pre><code>Unexpected token in JSON at position 39 at JSON.parse (&lt;anonymous&gt;)
  </code></pre>
  
  <p>I think JSON object manipulation is having some problem. </p>