前端控制台:shopoperation.js:14 Uncaught TypeError: Cannot read property 'map' of null(anonymous function) @ shopoperation.js:14v @ zepto.min.js:2S.onreadystatechange @ zepto.min.js:2
前端代码:
$(function(){ var initUrl='/o2oV1/shopadmin/getshopinitinfo'; var registerShopUrl='/o2ov1/shopadmin/registershop'; alert(initUrl); getShopInitInfo(); function getShopInitInfo(){ $.getJSON(initUrl,function(data){ if(data.success){ var tempHtml=''; var tempAreaHtml=''; //错误点14行 data.shopCategoryList.map(function(item,index){ tempHtml+='<option data-id="'+item.shopCategoryId+'">'+ item.shopCategoryName+'</option>'; }); data.areaList.map(function(item,index){ tempAreaHtml+='<option data-id="'+item.areaId+'">'+item.areaName +'</option>'; }); $('#shop-category').html(tempHtml); $('#area').html(tempAreaHtml); } }); $('#submit').click(function(){ var shop={}; shop.shopName=$('#shop-name').val(); shop.shopAddr=$('#shop-addr').val(); shop.phone=$('#shop-phone').val(); shop.shopInfo=$('#shop-info').val(); shop.shopCategory={ shopCategoryId:$('#shop-category').find('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('shopImg',shopimg); formData.append('shopStr',JSON.stringify(shop)); $.ajax({ url:registerShopUrl, type:'POST', data:formData, contentType:false, processDate:false, cache:false, success:function(data){ if(data.success){ $.toast('提交成功!') }else{ $.toast('提交失败'+ data.errMsg); } } }); }); } })
SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需
了解课程