javascript - JSON.parse from php's json_encode issue -
running issue parsing json recieved php backend. on php have array, send json_encode:
$result[] = (object) array('src' => "{$mergedfile}", 'thumb_src' => "{$thumb_file}"); echo json_encode($result);
and when trying json.parse recieve error:
"uncaught syntaxerror: unexpected token f"
the response looks like:
[{"src":"upload\/lessons\/963\/video\/176481500-m.webm","thumb_src":"upload\/lessons\/963\/slide\/thumb_0f515a62753626e1aaefdc7968e8103e.jpg"}]
very strange thing that, similar code works nearby.. looks fine.. appreciate help, thanks.
you cannot json.parse()
json, param must string :
json.parse('[{"src":"upload\/lessons\/963\/video\/176481500-m.webm","thumb_src":"upload\/lessons\/963\/slide\/thumb_0f515a62753626e1aaefdc7968e8103e.jpg"}]');
the error receive can reproduced :
json.parse([{"src":"upload\/lessons\/963\/video\/176481500-m.webm","thumb_src":"upload\/lessons\/963\/slide\/thumb_0f515a62753626e1aaefdc7968e8103e.jpg"}]);
Comments
Post a Comment