The. Serializearray () serializes the table element (similar to the '. Serialize () ' method) to return the JSON data structure. (Excerpt from the jquery document).
There is one of the following form windows, code:
Copy Code code as follows:
<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> Contact Mobile:</th>
<td>
<input type= "text" name= "Mobile" id= "Txtmobile" maxlength= "one"/>
</td>
</tr>
<tr>
<TD style= "Text-align:center" colspan= "2" >
<input type= "button" value= "submitted" style= "padding-top:3px" name= "Butsubmit" id= "" Butsubmit "/>
</td>
</tr>
</table>
</form>
JavaScript code processing forms:
Copy Code code as follows:
<script>
$ (function () {
$ ("#butsubmit"). Click (function () {
var data = Convertarray ($ ("#tf"). Serializearray ());
$.post (URL, data, function (d) {}, "JSON");
});
})
function Convertarray (o) {//The main recommendation is to do this. It turns jquery's serialized value into Name:value form.
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>