The form submission method used in the project prior to , using the form () methods to detach the submit event from the Submit button and bind to any event, here's a good example to see below
Forms submitted in previous projects use the form () method to detach the submit event from the Submit button and bind to any event code as follows: Function Addsubmit () { $ (' # AddForm '). Form (' Submit ', { URL: _basepath + '/@Controller/@RequestMapping ', onsubmit:function () { if (Boolean) {//placement can submit judgment conditions $.messager.show ({ title: ' Hint ', msg: ' does not conform to the save condition ', showtype: ' fade ', Style:{right: ', Bottom: '} } '; return false;//block form submission } (' #addForm '). Form (' Validate '); To determine whether all required items are of value }, success:function (data) { var obj = Jquery.parsejson (data); Converts the returned JSON to the desired object (responsedata) if (!obj.success) {//To determine the property value $.messager.show of the indicated state in the returned ResponseData object ({ title: ' Hint ', msg: ' Save failed ', showtype: ' fade ', style:{right: ', bottom: '} } '; } else { $. Messager.show ({ title: ' Hint ', msg: ' Save Success ', showtype: ' fade ', style:{right: ', bottom: '} } '); $ ("# Addwin "). Window (" close ");/Turn off commit pwkk query ()//Refresh result set } } }); } today in the sharpJQuery also reads a submission that uses Ajax to encapsulate the form content with post submission code as follows: $ ("#btn"). Click (function () { $.get ("get.php", {username: $ ("#username"). Val (), password:$ ("#password"). Val ()}, function (data, textstatus) {///post the data in the form as a package upload $ ("# Target "). HTML (data)//fill the return value into the page }); }); then a simplified version, using the Serialize () method serialization code as follows: $ (" #btn "). Click (function () { $.get ("get.php", $ ("#form"). Serialize (), function (data, textstatus) {///The data in the form is taken out and encapsulated and uploaded $ ("#target"). HTML (data)//Fill return value to page }); }); Serialize () method can be automatically encoded, Also, objects such as a checkbox, other than forms, can be converted also have the Serializearray () method to serialize the elements and return the JSON object in the form of the array, not the JSON string That is, you do not need to use the Jquery.parsejson () method for conversion return values directly using such methods as $.each ()