JavaScript 解析后端 JSON 的注意事项

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30071413/article/details/82692314
var text=JSON.parse(xmlhttp.responseText);
document.getElementById("info").innerText=text["data"]["id"];
  • 使用JSON.parse将json字符串转换为JavaScript对象,否则显示 undefined
  • 要将json解析到最小元素,否则显示 [Object,Object]

猜你喜欢

转载自blog.csdn.net/qq_30071413/article/details/82692314