jquery parsing json appears SyntaxError:JSON.parse:unexpected character at line 1 column 2 of the JSON data

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.