bigface6

跨域请求(通过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  敲代码的小玉米  阅读(108)  评论(0编辑  收藏  举报

分类:

技术点:

相关文章:

  • 2021-11-07
  • 2021-11-30
  • 2021-07-07
  • 2021-04-07
  • 2021-12-08
  • 2021-09-09
  • 2022-01-09
猜你喜欢
  • 2021-11-05
  • 2022-01-01
  • 2021-12-28
  • 2021-11-05
  • 2021-11-05
  • 2021-09-02
  • 2021-12-06
相关资源
相似解决方案