I have a form on my site like this:
<form id="myform" action="" method="">
<input type="text" name="name[1][first]">
<input type="text" name="name[2][first]">
<input type="text" name="name[3][first]">
</form>
I want to simply grab all the data and send it to a webservice so have this js:
$fields = $('#myform').serializeArray();
Problem is, it creates the json with all the brackets shown in the input names so I get a parse error.
How can I use serializeArray and get proper json?
The resulting format that I would like to see is something like this:
{
"name": {
"1": {
"first": "val1"
},
"2": {
"first": "val2"
},
"3": {
"first": "val3"
}
}
}
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…