javascript - json unexpected token error on a json string generated by json_encode() -
i'm having trouble ajax/json
php json_encode() generated json code:
[{"createddate":"2013-08-16 13:23:35","body":"kpk"}, {"createddate":"2013-08-16 13:20:18","body":"iji"}, {"createddate":"2013-08-16 13:17:34","body":"kp"}, {"createddate":"2013-08-16 13:17:16","body":"kp"}, {"createddate":"2013-08-16 13:15:11","body":"koml"}, {"createddate":"2013-08-16 13:14:08","body":"lplpp,"}, {"createddate":"2013-08-16 13:13:59","body":"lplpp,"}, {"createddate":"2013-08-16 13:10:51","body":"mpmkp"}, {"createddate":"2013-08-16 13:10:29","body":"ook"}, {"createddate":"2013-08-16 13:07:48","body":"oomoloo"}] but keep on getting unexpected token error, can explain me why ?
the error thrown when try parse json string in following way:
function ajax_callback(mex) { mexx = json.parse(mex); //other stuff }
either mex variable not correct;
or
you not using variable mexx correctly, note mexx resulted array have use this: mexx[0].body
since, json correct. jsfiddle
Comments
Post a Comment