表单数据编辑

1.当$.get()得不到图片时,需要把两个图片的属性设置为相同的name
表单数据编辑_第1张图片
Paste_Image.png
![](@routes.Assets.versioned("img/logo_box.png"))
![]({{logoUrl}})
2.$get()到数据,用for循环显示出来

for

$.get("/cservices/" + serviceId, '')
  .done(function(data, status, xhr) {
    for(var key in data){
      if(key != 'avatarUrl' && key != 'wechatQRUrl'){
        $('[name="'+ key +'"]').attr('value', data[key]);
      }
    }
    $('#imgHeadPhoto').attr('src',data.avatarUrl);
    $('#imgWechat').attr('src',data.wechatQRUrl);
  }).always();

base

$.get("/user/extra", '')
      .done(function(data, status, xhr) {
        $('[name="eid"]').val(data.eid);
        $('[name="userId"]').val(data.userId);
        $('[name="imgLogo"]').prop('src',data.logoUrl);
        $('[name="crocsAddress"]').val(data.crocsAddress);
        $('[name="companyAddress"]').val(data.companyAddress);
        $('[name="contactPhone"]').val(data.contactPhone);
        $('[name="salesPhone"]').val(data.salesPhone);
        $('[name="qq"]').val(data.qq);
      }).always();

你可能感兴趣的:(表单数据编辑)