need form form submission, large form to field background manual processing too cumbersome. Or is it convenient to choose Form Form Object (entity.xx), then how does Ajax submit such form object forms?
Name Jquery.commons.js content as follows
/** * form Object Form Ajax pre-submission data processing methods * @param frm * @returns json object */function getformjson (frm) { var o = {}; var a = $ (frm). Serializearray (); $.each (a, function () { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[ this.name] = [o[this.name]]; } o[this.name].push (this.value | | "); } else { o[this.name] = this.value | | "; } }); Return o;}
Examples are as follows
var myForm = Getformjson ($ ("#myform")); $.ajax ({url: ' saveappoint.action ', type: ' POST ', Data:myform, SUCC Ess:function (data) {showmsg (data); }});
Form form Contents
<form id= "MyForm" ><input type= "hidden" id= "TimeType" name= "Appointment.timetype" readonly= "readonly" value= "<s:property value=" Appointment.timetype "/>"/><input type= "hidden" id= "Visitbegin" Name= " Appointment.visitbegin "readonly=" readonly "value=" <s:property value= "Appointment.visitbegin"/> "/>< Input type= "hidden" id= "Visitend" name= "Appointment.visitend" readonly= "readonly" value= "<s:property value=" Appointment.visitend "/>"/></form>
Action background
Private appointment appointment;public void Setappointment () {...} Public appointment getappointment () {...}
You can implement object form submission support.
Above, thank you!
Mo Mo Jin
This article from the "Mo Mo Gold It experience and skills" blog, reproduced please contact the author!
Foam Gold-jquery serialized Form form "Support Ajax submit Form Object Form Entity.xxx"