The $. Ajax method of jquery can be called by Ajax. You need to set URL, post, parameters, and so on.
If you want to submit an existing form, you need to write a lotCodeWhy not directly transfer form submission to Ajax.
Previous Handling Methods
The form code is as follows:
< Form ID = "Form1" Action = "Action. aspx" Method = "Post" >
Name:<InputName= "Name"Type= "Text" /> <BR/>
Password:<InputName= "Password"Type= "Password" /> <BR/>
Mobile phone:<InputName= "Mobile"Type= "Text" /> <BR/>
Note:<InputName= "Memo"Type= "Text" /> <BR/>
<InputType= "Submit"Value= "Submit" />
</Form>
After submission, the action. ASPX page is displayed. You can obtain the value through request. Params ["name.
// Convert the value in form to a key-value pair. Function Getformjson (FRM ){ VaR O = {}; VaR A = $ (FRM). serializearray (); $. Each (, 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 ;} Function Save_roomorder (){ VaR Datapara = getformjson ($ ('# form1' ); LG. Ajax ({loading: 'Saving the data ...', Type: "Ajax?manage" , Method: "Tts_assist_roomorder" , Data: datapara, success: Function (){ // DG. curwin. f_reload (); DG. curwin. LG. Tip ('saved successfully! ' ) ;}, Error: Function (Message) {LG. Tip (Message );}});}
The first parameter of the save_roomorder method is the form to be submitted, and the formatted form content is passed to Data.
The getformjson method converts form elements into JSON-format key-value pairs. For example, {Name: 'aaa', password: 'ttttt'}. Put the same name in an array.