Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
This is code snippet returning me json string

PHP
while($row = mysql_fetch_assoc($result))
   {
       $data[] = $row;
   }
   echo json_encode($data);


i am trying to parse it back to object but it showing me
Uncaught SyntaxError: Unexpected token N
while simple code is in js

$jq.get(go_path,
{
}, function(data)
{
C#
console.log(data);
          
          var myData = JSON.parse(data);//this making error:(
          console.log(typeof myData);


}
Posted
Comments
Sergey Alexandrovich Kryukov 10-Apr-15 12:08pm    
Input of the parse is not well-formed. You did not show a sample of input data, so I don't know where, but you should know it.
—SA
Muhamad Faizan Khan 13-Apr-15 0:14am    
absolutely right. I have fixed there were problem in format

1 solution

JavaScript
var myData = JSON.parse(data);


"data" that i were trying to parse not in correct format thats why it showing
Uncaught SyntaxError: Unexpected token N
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900