SyntaxError: JSON.parse: unexpected character

后端 未结 2 1756
梦毁少年i
梦毁少年i 2020-12-21 10:30

I have a JSON parse error that I can\'t debug. Code below:

$(document).on(\'submit\', \'#confirmreset\', function(event) {
    event.preventDefault();

    v         


        
相关标签:
2条回答
  • 2020-12-21 11:31

    You don't need to call $.parseJSON if the server is sending valid JSON as jQuery will parse it automatically when it retrieves the response. I don't know the exact criteria, but if you set the Content-type: application/json header it definitely will.

    0 讨论(0)
  • 2020-12-21 11:34

    This error can be caused by using single quotation marks (') instead of double (") for strings.

    The JSON spec requires double quotation marks for strings.

    See also:

    https://stackoverflow.com/a/14355724/1461850

    0 讨论(0)
提交回复
热议问题