Jquery - Ajax: SyntaxError: JSON.parse: unexpected character

后端 未结 3 1599
闹比i
闹比i 2021-01-27 09:36

I have the following code and output, and I cant fine any error on the json data to be decoded. Can anyone please help me in finding this error

CODE:

            


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-27 10:23

    jQuery is clever enough to parse the response as it is, even if dataType isn't specified.

    In your case, it is specified and therefore, it is already parsed and data is the parsed JSON object.

    What you are doing is therefore parsing an Object.

    Doc says:

    dataType: (default: Intelligent Guess (xml, json, script, or html))

    Type: String

    The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback) are:

提交回复
热议问题