Uncaught TypeError: Cannot read property 'dataset' of undefined

来源:4-13 前后端联调验证整体模块功能

慕莱坞5098839

2021-06-06

$('#submit').click(function (){
      var shop = {};
      shop.shopName = $('#shop-name').val();
      shop.shopAddr = $('#shop-addr').val();
      shop.phone = $('#shop-phone').val();
      shop.shopDesc = $('#shop-desc').val();
      shop.shopCategory = {
          shopCategoryId: $('#shop-category').val('option').not(function (){
              return !this.selected;
          }).data('id')};//显示这里错误
      shop.area={
          areaId:$('#area').find('option').not(function (){
              return !this.selected;
          }).data('id')
      };
      var shopImg = $('shop-img')[0].files[0];
      var formData = new FormData();
      formData.append('shop-img',shopImg);
      formData.append('shopStr', JSON.stringify(shop));
      $.ajax({
          url:registerShopUrl,
          type:'POST',
          data:formData,
          contentType:false,
          processData:false,
          cache:false,
          success:function (data){
              if (data.success){
                  $.toast('提交成功!')
              }else {
                  $.toast('提交失败!' + data.error);
              }
          }
      })

  })
  }
})

sm.min.js:7 Uncaught TypeError: Cannot read property ‘dataset’ of undefined
at Array.a.fn.dataset (sm.min.js:7)
at Array.a.fn.data (sm.min.js:7)
at HTMLAnchorElement. (sp.js:34)
at HTMLAnchorElement.s.proxy (zepto.min.js:2)

不知道问题出在哪里

写回答

1回答

翔仔

2021-06-06

同学好,这个需要前后端调试一下,看看你的shopcategorylist和arealist后端是否获取到并传给前端了,前端拿到是否展示了

0
0

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5113 学习 · 8144 问题

查看课程