weixin_46506068
2022-02-14 09:49
采纳率: 100%
浏览 28
已结题

layui中使用ajax获取嵌套类数据失败

问题遇到的现象和发生背景

layui中使用ajax获取嵌套类数据失败

问题相关代码,请勿粘贴截图
  $(function () {
        var doctorCode = getParam("doctorCode");
        $.ajax({
            url:"/SSM_hospital/doctor/queryDoctorByDoctorCode",
            type:'post',
            data:{"doctorCode":doctorCode},
            dataType:'json',
            success:function (d) {
                //解析数据
                $("#doctorCode").val(d.doctorCode);
                $("#doctorName").val(d.doctorName);
                $("#doctorSex").val(d.doctorSex);
                $("#doctorBirthday").val(d.doctorBirthday);
                $("#doctorPhone").val(d.doctorPhone);
                $("#doctorAddress").val(d.doctorAddress);
                $("#doctorPost").val(d.doctorPost);
                //$("#doctorDeptId").val(d.dept.id);
                //医生部门的id获取不到
                $("#doctorMajor").val(d.doctorMajor);
                $("#doctorProfile").val(d.doctorProfile);
                layui.use('form',function () {
                    var form = layui.form;
                    form.render();
                })
            }
        })

public class Doctor {
        private String doctorCode;
        private String doctorPassword;
        private String doctorName;//真实姓名
        private int doctorSex;
        private int doctorAge;
        private String doctorPost;//职位
        private String doctorPhone;
        private String doctorBirthday;
        private String doctorProfile;//个人简介
        private String doctorMajor;//主修;擅长
        private String doctorAddress;
        //部门
        private Dept dept;




public class Dept {
    private int id;
    private String deptName;
    private String deptAddress;
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题