title: How to correctly parse Json from php json_encode
body: <p>I want to parse json data created by PHP json_encode in my front end app, i can't do this: </p>
  
  <pre class="lang-js prettyprint-override"><code>var data= '&lt;?php echo $jsonarr; ?&gt;';
  </code></pre>
  
  <p>As it is a Cordova app.
  Here is my php code: </p>
  
  <pre><code> &lt;?php
   $arr_login= array("lname"=&gt;"$rowlname","email"=&gt;"$rowemail","fname"=&gt;"$rowfname","mobile"=&gt;"$rowmobile");
    echo json_encode($arr_login);
   ?&gt;
  </code></pre>
  
  <p>My ajax code:</p>
  
  <pre class="lang-js prettyprint-override"><code>   $.ajax({
     type:"POST",
     url: url,
     data:data,
     success: function(data){
     var res = $.trim(data);
     if (res == "Password is inccorrect" || res== "Email is inccorrect") {
      $("#errmsg").html(data);
     }
       else{
       var response= JSON.parse(data);
       alert(response);
       //window.open("dashboard.html?sess=logined&amp;","_self");
  
       }
   }
  
       });
  </code></pre>
  
  <p>Now if I alert data it gives me the valid JSON format as sent by PHP, but I need to convert it to javascript object so I can use it in DOM but JSON.parse gives this error in the console:</p>
  
  <pre><code> VM236:14 Uncaught SyntaxError: Unexpected token / in JSON at position 147
  </code></pre>