wx.request向后臺請求數據,后臺echo json_encode($res)返回。這時小程序接收到數據,該如何處理?【注:$res是一個二維數組】wx.request請求代碼? getmynh: function (sessionid){? ? var that = this;? ? wx.request({? ? ? url: 'https://xing.zhumingke.cn/index.php/home/index/getmynh',? ? ? data:{? ? ? ? unionid: sessionid? ? ? },? ? ? header: {? ? ? ? 'content-type': 'application/json'? ? ? },? ? ? dataType:'json',? ? ? success:function(res){? ? ? ? console.log(res)? ? ? ? console.log(res.data)? ? ? ? console.log(typeof(res.data))? ? ? ? that.getsomething(res)? ? ? }? ? })? },后端返回數據代碼public function getmynh(){? ?$unionid = I('get.unionid');? ?$user = M("nhuser");? ?$res1 = $user->where(array('unionid'=>$unionid))->find();? ?$phone = $res1['phone'];? ?$nhcont = M("nhcont");? ?$res2 = $nhcont->where(array('fromphone'=>'13922186065'))->field('nhcont',true)->select();? ?if(is_array($res2) && !empty($res2)){? ? ? ?$aaa = json_encode($res2);? ? ? ?$yt = gettype($aaa);? ? ? ?file_put_contents(THINK_PATH.'log/log86.txt',$yt);? ? ? ?echo json_encode($res2);? ?}else{? ? ? ?echo "0";? ?}}
小程序 wx.request請求到數據,需要怎樣處理才能渲染出來?
qq_欠你的幸福_0
2017-09-05 20:28:24