JQuery getJSON - ajax parseerror

后端 未结 17 1914
南笙
南笙 2020-12-01 13:04

I\'ve tried to parse the following json response with both the JQuery getJSON and ajax:

[{\"iId\":\"1\",\"heading\":\"Management Services\",\"body\":\"

17条回答
  •  囚心锁ツ
    2020-12-01 13:30

    The value you are trying to parse is wrapped in brackets [], which means it is an array. You are trying to eval an array. Try to eval the first element of the array, and it should work...

    var json = eval("("+data[0]+");");
    

    Also, I would recommend using the JSON.parse() provided here instead of calling eval() directly.

提交回复
热议问题