猫小怪

世人慌慌张张,不过图碎银几两。

 

跨域请求(通过id获取用户整个信息并返回到前台)

前台页面

 jQuery.ajax({
           type: "get",
           url: Apiurl+"user/userinfo",
           dataType: "json",
           data:{
               'userid':user,(用户id
           },

//赋值给前台页面
           success: function (arr) {
               $('#nickname').html(arr.nicheng);

$('#text').html(arr.nicheng);

               $('#username').html(arr.phone);

$('#pics').html(arr.pic);
           },
           error:function(){
               console.log('请求失败');
           }
       })

控制器

public function userinfo(){
    $userinfo = M('user');
    $data = $userinfo->where('id='.$_GET['userid'])->find();
    $this->ajaxreturn($data);die;

}

posted on 2020-06-08 20:33  猫小怪  阅读(201)  评论(0编辑  收藏  举报

导航