問題背景
1、apicloud+ssh框架交互
2、ajax返回後臺的數據
3、alert(JSON.stringify( ret ) );處理一大堆的數據
ret返回的結果很多,但是我想獲取 body裏面tom的值,怎麼辦呢?總不能用string的分割來處理吧,那個有點麻煩啊?
問題簡單描述
我想獲取body裏面的tom的值
做過的嘗試
1、alert(ret);
結果是[Object Object]
2、alert(ret.body);
結果是body id undefined
3、alert(ret[0].body);
結果 報錯
正確的取值方式來了
第一種:對象名.屬性
var object=JSON.stringify( ret.body.tom);
alert(object);
結果如下:
第二種、String字符串的切割技術
https://blog.csdn.net/qq_37591637/article/details/88367603