First, you have to initialize the URL, a load of this JS, the execution of this URL, to initialize
The Getshopinitinfo in Initurl is to obtain store classification and area information, to perform the front-end store classification and to initialize the drop-down menu of the owning area.
Registershopurl is the registration of the store, that is, the information added in the previous web-inf/html/shop/shopoperation.html, through this URL returned to the background controller processing, to register the store
which
$ (function () {var initurl = '/shopadmin/getshopinitinfo '; var registershopurl = '/shopadmin/registershop '; alert (Initurl); /* This method is to obtain store classification and area information, perform the front-end store classification and the drop-down menu of the owning area (getshopinitinfo). function Getshopinitinfo () {$.getjson (Initurl, function (data) {if (data.success) {var temp Html = '; var tempareahtml = '; Data.shopCategoryList.map (function (item, index) {temphtml + = ' <option data-id= "' + item.shopcategory Id + ' > ' + 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.shopdesc = $ (' #shop_desc '). Val (); /* Use the drop-down menu to make a selection, get the value of the method */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 '); }; /* Gets the input stream of the uploaded image */var shopimg = $ (' #shop_img ') [0].files[0]; The parameters passed in Ajax are var formData = new FormData (); The contents of the parameters, respectively, are above the shop and shop pictures formdata.append (' shopimg ', shopimg); Formdata.append (' Shopstr ', json.stringify (shop)); /* Use AJAX to submit to background */$.ajax ({url:registershopurl, type: ' POST ', data:fOrmdata, Contenttype:false, Processdata:false, Cache:false, succes S:function (data) {if (data.success) {$.toast (' Submit succeeded! ‘); } else{$.toast (' Submit failed! ' + data.errmsg); } } }) }); }})
Then add the JS tag to the shopoperation.html
<script type= ' text/javascript ' src= '. /resources/js/shop/shopoperation.js ' charset= ' utf-8 ' ></script>
Shop--6. Store Registration--JS Implementation