. Serializearray () serializes table elements (similar to the '. serialize ()' method) and returns JSON
Data structure data. (From the jquery document ).
There is a form window,Code:
<Form action = "" method = "Post" id = "TF">
<Table
Width = "100%" cellspacing = "0" cellpadding = "0"
Border = "0">
<Tr>
<TH> name: </Th>
<TD>
<Input type = "text"
Id = "txtusername" name = "username"/>
</TD>
<TH> mobile phone number: </Th>
<TD>
<Input type = "text" name = "mobile"
Id = "txtmobile" maxlength = "11"/>
</TD>
</Tr>
<Tr>
<TD style = "text-align: center ;"
Colspan = "2">
<Input type = "button" value ="
Submit "style =" padding-top: 3px; "name =" butsubmit"
Id = "butsubmit"/>
</TD>
</Tr>
</Table>
</Form>
JavaScript code Processing Form:
<SCRIPT>
$ (Function ()
{
$ ("# Butsubmit"). Click (function (){
VaR DATA =
Convertarray ($ ("# TF"). serializearray ());
$. Post (URL, Data, function (d)
{}, "JSON ");
});
})
Function convertarray (o ){
// This function is recommended. It converts the serialized value of jquery into the name: Value format.
VaR v = {};
For (VAR I
In O ){
If (typeof (V [O [I]. Name]) = 'undefined') V [O [I]. Name] =
O [I]. value;
Else V [O [I]. Name] + = "," + O [I]. value;
}
Return V;
}
</SCRIPT>
. Serializearray () serializes table elements (similar to the '. serialize ()' method) and returns JSON
Data structure data. (From the jquery document ).
There is a form window with the code:
<Form action = "" method = "Post" id = "TF">
<Table
Width = "100%" cellspacing = "0" cellpadding = "0"
Border = "0">
<Tr>
<TH> name: </Th>
<TD>
<Input type = "text"
Id = "txtusername" name = "username"/>
</TD>
<TH> mobile phone number: </Th>
<TD>
<Input type = "text" name = "mobile"
Id = "txtmobile" maxlength = "11"/>
</TD>
</Tr>
<Tr>
<TD style = "text-align: center ;"
Colspan = "2">
<Input type = "button" value ="
Submit "style =" padding-top: 3px; "name =" butsubmit"
Id = "butsubmit"/>
</TD>
</Tr>
</Table>
</Form>
JavaScript code Processing Form:
<SCRIPT>
$ (Function ()
{
$ ("# Butsubmit"). Click (function (){
VaR DATA =
Convertarray ($ ("# TF"). serializearray ());
$. Post (URL, Data, function (d)
{}, "JSON ");
});
})
Function convertarray (o ){
// This function is recommended. It converts the serialized value of jquery into the name: Value format.
VaR v = {};
For (VAR I
In O ){
If (typeof (V [O [I]. Name]) = 'undefined') V [O [I]. Name] =
O [I]. value;
Else V [O [I]. Name] + = "," + O [I]. value;
}
Return V;
}
</SCRIPT>