Shop--6. Store Registration--JS Implementation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.