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"; }}
添加回答
举报
0/150
提交
取消