Reading JSON data (created by PHP) via jQuery Ajax results in "parserror" -


i create json-data following php code:

if($res =  $db->query('select row1 table1')){     while($row = $res->fetch_row()){         $json[] = $row;     } } sort ($json); $json = json_encode($json); echo $json; 

the result [["1"],["2"],["3"]].
when try fetch data jquery ajax

<div id="output">json put here</div> <script language="javascript" type="text/javascript">     $(function ()   {     $.ajax({                 url: 'json.php',                 datatype: 'json',                 data: '',                  error: function(request,error) {                             alert(error);                             },                 success: function(data) {                     var json = data[0];                     alert(json);                     $('#output').html(json+", ");                     }                 });             }); 

it says: "parseerror".
searched lot (here @ stack overflow), jquery version seem right (1.7.2) , reformating json-outpu did not (i deleted opening brackets , tried lot of other things).
ideas?

parse data return in ajax result,

var retdata= json.parse(data); 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -