SPRINGMVC and Easyui use Ajax foreground background to pass data, false delete hint warning problem.

Source: Internet
Author: User

Front desk

//Delete multiple/single datafunctiondel (CID) {varId= "; if(cid== '-1 '){        if(Getselections (). length > 0) {ID=getselections (); }Else{$.messager.alert (Prompt, select the row to delete, error); return; }    }Else{ID=CID; }     varArr =id.split (":");//split the selected special Guardian ID      for(vari = 0; i < arr.length; i++){         varDelorder =Isconfirmorder (Arr[i]); }}functionIsconfirmorder (ID) {parent.window.$ ("#loadingImg"). CSS ("Display", "" "); $.ajax ({URL:'/livemanager/sg/delspecialguardinfo ',//② Background URLData: {' IDs ': ID, ' Queryorder ': 2},//① Pass in the ID parameter and the Queryorder parameter to the background (inquire if there is an appointment)Type: ' POST ', DataType:' JSON ', Async:true, Success:function(data) {varConfirmdelorder = "0"; //console.info ("Data", data);                if(Data.isorder = = 0) {//13: No appointment directly delete, refreshparent.window.$ ("#loadingImg"). CSS ("display", "none"); $(' #tt '). DataGrid (' Reload ');                    Clearselections (); return; }                 if(Data.isorder = = 1) {//⑦ proof that the reserved special is to be deleted.                    //⑧ prompt whether to confirm deletion$.messager.confirm ("Prompt", Data.name + "have reservation not completed, confirm deletion?") ",function(r) {if(R) {parent.window.$ ("#loadingImg"). CSS ("Display", "" "); $.ajax ({URL:'/livemanager/sg/delspecialguardinfo ', data: {' IDs ': ID, ' Queryorder ': 1},//⑨ Delete the URL, pass the parameter ID and QueryorderType: ' POST ', DataType:' JSON ', Success:function() {parent.window.$ ("#loadingImg"). CSS ("display", "none"); $(' #tt '). DataGrid (' Reload ');                                    Clearselections (); $.messager.alert ("Prompt", "Operation succeeded", "success");                          }                            });                }                      }); } parent.window.$ ("#loadingImg"). CSS ("display", "none"); $(' #tt '). DataGrid (' Reload ');            Clearselections (); }      });}

Background

@RequestMapping (value= "Delspecialguardinfo", method=requestmethod.post) Public voidDelspecialguardinfo (httpservletrequest request,httpservletresponse response, @RequestParam ("IDs") String ids,@ Requestparam ("Queryorder") Integer Queryorder)throwsioexception{//③ receive the passed parameter Ids,queryorderMap<string,object> status=NewHashmap<string,object>(); if(ids!=NULL&&! "". Equals (IDs)) {            Booleanboo=false; List<String> list=Specialguardservice.findsgidformorder (); Specialguardinfo Order=specialguardservice.findspecialguardinfobyid (IDS); Boo=list.contains (IDS);//Determines whether the ID number represented by the string variable is in the list, and the list represents the special position with the appointment                if(Boo) {//④ Existence Reservation                    if(Queryorder = = 1) {//⑤ The front is 2, do not perform this if//⑩ previous section confirm Delete Pass Queryorder=1 perform deleteOrder.set_state (0);                    } specialguardservice.save (order); Status.put ("Isorder", 1);//⑥ transfer parameters to the foregroundStatus.put ("name", Order.getname ()); Status.put ("Status", 200); } Else{//11: No reservation available, delete directlyOrder.set_state (0);                        Specialguardservice.save (order); Status.put ("Isorder", 0);//12: After the deletion to the foreground to pass parameters isorder=0Status.put ("status", 200); }                    }Else{status.put ("Status", 201); } response.setheader ("Access-control-allow-origin", "*"); Response.setheader ("Access-control-allow-methods", "Get,post"); Returnjson (response, status);//Remember to return submit data}

SPRINGMVC and Easyui use Ajax foreground background to pass data, false delete hint warning problem.

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.