title: JSON error : SyntaxError: JSON.parse: unexpected character at line 2 column 1 of the JSON data
body: <p>what is the error here :</p>
  
  <pre><code>.done(function(data) {
                  var json = JSON.parse( data );
                  if(json['status'] === "success"){
                      //some processing
                  }
                  else {
                      alert( "error 2" );
                  }
              })
  </code></pre>
  
  <p>I got the error message on:  var json JSON.parse('('+data+')')</p>
  
  <p>data is returned from a php script :</p>
  
  <pre><code>/*...............*/
  $sql-&gt;execute();
  $i = 0;
  while($result = $sql-&gt;fetch(PDO::FETCH_ASSOC){
      $response["affiliates"][i]["affiliate_name"] = $result["coupon_name"];
      $response["affiliates"][i]["affiliate_id"] = $result["coupon_id"];
      $i++;
  }
  $response["status"] = "success";
  echo json_encode($response); 
  </code></pre>