Jquery Method for ajax form submission
This article mainly summarizes jquery's method for implementing ajax form submission. If you need it, you can refer to it and hope to help you.
Method 1:
The Code is as follows:
Function AddHandlingFeeToRefund ()
{
Var AjaxURL = "../OrderManagement/AjaxModifyOrderService. aspx ";
Alert ($ ('# formaddhandlinger'). serialize ());
$. Ajax ({
Type: "POST ",
DataType: "html ",
Url: AjaxURL + '? Action = '+ 'submithandlinger' +' & OrderNumber = '+ $. trim ($ ("# <% = this.txt OrderNumber. ClientID %>"). val ()),
Data: $ ('# formaddhandlinger'). serialize (),
Success: function (result ){
Var strresult = result;
Alert (strresult );
// Load the maximum refundable amount
$ ("# SpanMaxAmount" cmd.html (strresult );
},
Error: function (data ){
Alert ("error:" + data. responseText );
}
});
}
Method 2:
The Code is as follows:
// Ajax form submission method
$ ('# FormAddHandlingFee'). submit (function (){
Var AjaxURL = "../OrderManagement/AjaxModifyOrderService. aspx ";
Alert ($ ('# formaddhandlinger'). serialize ());
$. Ajax ({
Type: "POST ",
DataType: "html ",
Url: AjaxURL + '? Action = '+ 'submithandlinger' +' & OrderNumber = '+ $. trim ($ ("# <% = this.txt OrderNumber. ClientID %>"). val ()),
Data: $ ('# formaddhandlinger'). serialize (),
Success: function (data ){
Var strresult = data;
Alert (strresult );
// Load the maximum refundable amount
$ ("# SpanMaxAmount" cmd.html (strresult );
},
Error: function (data ){
Alert ("error:" + data. responseText );
}
});
}
);
Page html code:
The Code is as follows:
<Form id = "formaddhandling.pdf" name = "formaddhandling.pdf" enctype = "multipart/form-data" onsubmit = "AddHandlingFeeToRefund ()">
<Table id = "addhandling.pdf" class = "Wfill">
<Tr>
<Td>
<Asp: Literal ID = "UI_Amount" runat = "server" Text = "processing fee" meta: resourcekey = "HandlingFeeAmount"/>
</Td>
<Td>
<Input type = "text" id = "txtHandlingFeeAmount" name = "txtHandlingFeeAmount" class = "{required: true, number: true}" maxlength = "12"/>
</Td>
</Tr>
<Tr>
<Td>
<Asp: Literal ID = "UI_HandlingFeeType" runat = "server" Text = "billing type" meta: resourcekey = "HandlingFeeHandlingFeeType"/>
</Td>
<Td>
<Crmweb: HtmlSelectControl ID = "HandlingFeeType" EnumTypeName = "DX. OMS. model. common. handlingFeeType, DX. OMS. model. common "EmptyValue =" "EmptyText =" Select "runat =" server "class =" text {required: true} "/>
</Td>
</Tr>
<Tr>
<Td>
<Asp: Literal ID = "UI_Notes" runat = "server" Text = "Remarks" meta: resourcekey = "HandlingFeeNotes"/>
</Td>
<Td>
<Textarea id = "txtNotes" name = "txtNotes" class = "text {required: true} "cols =" 22 "rows =" 2 "maxlength =" 100 "> </textarea>
</Td>
</Tr>
<Tr>
<Td>
</Td>
<Td>
<Input id = "Submit1" type = "submit" value = "add processing fee"/>
<Asp: Button ID = "Button1" runat = "server" Text = "add processing fee" OnClientClick = "javascript: AddHandlingFeeToRefund ()"/>
</Td>
</Tr>
</Table>
</Form>