I keep getting “Uncaught SyntaxError: Unexpected token o”

前端 未结 9 1899
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 01:46

I\'m trying to learn some html/css/javascript, so I\'m writing myself a teaching project.

The idea was to have some vocabulary contained in a json file which would t

9条回答
  •  庸人自扰
    2020-11-22 02:13

    Basically if the response header is text/html you need to parse, and if the response header is application/json it is already parsed for you.

    Parsed data from jquery success handler for text/html response:

    var parsed = JSON.parse(data);
    

    Parsed data from jquery success handler for application/json response:

    var parsed = data;
    

提交回复
热议问题