This article mainly introduces the Ajax synchronous verification of the existence of the method, involving Ajax-based data interaction related operation skills, the need for friends can refer to, hope to help everyone.
The method that is executed before the save, Ajax synchronous call background verifies whether the package number exists function Dobeforesave () { var Packagecode=document.getelementbyid ("PackageCode "). Value; var Temp=false; if (packagecode!= "") { $.ajax ({ URL: "${ctx}/finance/packagemanagement!parcelswhetherexists.do",//Receive Page type: ' Post ', //post way to send data async:false, //ajax sync data:{packagecode:packagecode}, Success:function (Result) { temp = eval (result.result); } }); } if (!temp) { alert ("The package number already exists!") "); Toft.resetform ("Adddataform");//clear the form toft.id ("PackageCode"). focus () ; return temp;}