SyntaxError:JSON.parse:unexpected character at line 1 column 2 of the JSON data
I had this error when I used $.parsejson to parse the JSON data returned from the background, and I thought there was an error in the JSON format that was returned because the JSON requires a very strict format. Finally found that the JSON format is not too obvious format error, I use Fastjson to generate the JSON format data, originally because the data is already a JavaScript object, so parsing will be wrong
I alert the data directly and use TypeOf to verify its type and find it to be an object, which proves that the data has become a JavaScript object. So, I directly use (not what Parsejson parse) this data to the corresponding processing will not be wrong
$.ajax ({URL:' Commentaction_showcomment ', type:' POST ', data:{TitleID: $ (comment_this). attr (' Data-id '), Currpage:currpage,}, Beforesend:function(JQXHR, Settings) {$ ('. Comment_list '). EQ (index). Append (' <dl class= ' comment_load ' ><dd> loading comments </dd></dl> '); }, Success:function(response, status) {varJson_comment =response; }, });
Perhaps my parsejson approach to jquery is wrong to use, or should it be handled in a different way?
jquery parsing json appears SyntaxError:JSON.parse:unexpected character at line 1 column 2 of the JSON data