0001: response
$[0] = [string] "{\"code\":200,\"id\":121}"
0001: eval(response)
SyntaxError: invalid label
Run Code Online (Sandbox Code Playgroud)
有谁知道?
Nic*_*ver 14
您必须将其包装()
以触发表达式评估,如下所示:
eval("(" + response + ")")
Run Code Online (Sandbox Code Playgroud)
虽然更好的方法是本机JSON处理:
var result = JSON.parse(response);
Run Code Online (Sandbox Code Playgroud)
只需将json2.js包含在较旧的浏览器(<IE8)支持中,调用是相同的...它只是添加全局JSON
对象(如果它缺失).