SPRINGMVC Ajax+select The common way of the dropdown box interaction

Source: Internet
Author: User

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "UTF-8"><title>Insert Title here</title>    <Scripttype= "Text/javascript"src=".. /js/jquery-1.8.0.min.js "></Script><Script>//Ajax+select Three common ways of interactingwindow.onload=function() {test ();}functionTest () {alert ("Execution"); varStart= 0; varsize= -; varHeadno= "111111"; $.ajax ({type:"Post", URL:"/ssm_pms/admin_group/list", //change this URL to the URL you really needdata: {"Headno": Headno,"Start": Start,"size": Size}, DataType:'JSON', Success:function(data) {LoadData (data.hotelchainlist); },error:function() {alert ("Error");        }    }); varLoadData=function(list) { for (varI= 0; I<list.length; I++) {                        $("#hotelNo"). Append ("<option value="+list[i].hotels[0].hotelno+">"+list[i].hotels[0].hotelname+"</option>")        }    }/*$.ajax ({type: "post", url: "/ssm_pms/admin_group/list",//This URL is changed to the URL that really needs data: {"Headno ": Headno," Start ": Start," size ": size}, DataType: ' JSON ', success:function (d ATA) {$.each (data.hotelchainlist, function (index, item) {$ ("#hotelNo"). Append (//Here, loop to select            Bind data "<option value=" +item.hotels[0].hotelno+ ">" + item.hotels[0].hotelname+ "</option>");        }); },    }); *//*$.ajax ({type: "post", url: "/ssm_pms/admin_group/list",//This URL is changed to the URL that really needs data: {"Headno" : Headno, "Start": Start, "size": size}, DataType: ' JSON ', Success:function (da            TA) {alert (data.returnmsg);            var list = Data.hotelchainlist; for (var i = 0; i < list.length; i++) {alert (List[i].hotels[0].hotelno) $ ("#hotelNo"). AP Pend ("<option value= ' 1 ' >" +list[i].hotels[0].hotelname+ "</option>")}},e        Rror:function () {alert ("error"); }    }); */}</Script></Head><Body><SelectID= "Hotelno">             <option>Please select a hotel</option></Select></Body></HTML>

The above three ways, I pro-test effective, this is more commonly used, especially the front-end interaction, take the hotel management system, department staff and so on related to the dropdown box linkage, of course, there are many application scenarios.

Background code for Java code, SPRINGMVC, this is the Web layer framework, is now more commonly used, very famous.

The SPRINGMVC code is:

/*** Check the company's hotel store length information and its role information *@paramStart *@paramSize *@paramHeadno *@paramMap *@return     */@PostMapping (Value= "Managerlist", produces= "Application/json;charset=utf-8") @ResponseBody PublicString managerlist (Integer start,integer size,string headno,map<string,object>map) {                        //Role number is 3 store lengthString roleno= "3"; Map.put ("Headno", Headno); Map.put ("Roleno", Roleno); Map.put ("Start", start); Map.put ("Size", size); //Call Query group method of hotel store length information and its Role information collectionListhotelchainservice.selectmanagerinfolist (map); intLines =hotelchainservice.selectmanagercount (map); //Call Query group The hotel store length information and its role information total methodMap<string,object> Returnmap =NewHashmap<string,object>(); //returns different result sets based on the result of the decision        if(Lines!=0 && hotelchainlist.size ()!=0) {Returnmap.put ("Hotelchainlist", hotelchainlist); Returnmap.put ("Lines", lines); Returnmap.put ("ReturnCode", "000000"); Returnmap.put ("Returnmsg", "Get to Data"); }Else{returnmap.put ("ReturnCode", "111111"); Returnmap.put ("Returnmsg", "No data acquired"); }                returnjson.tojsonstring (RETURNMAP); }    

SPRINGMVC Ajax+select The common way of the dropdown box interaction

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.