i've got some form input elements in an html table like this:
<table>
<thead>
....
</thead>
<tr>
<td><input type="text" name="n_time" id="5030c9261eca0" value="2012" /></td>
<td><input type="text" name="n_name" id="5030c9261eca0" value="a name" /></td>
<td><textarea name="n_comment" id="5030c9261eca0">bla</textarea></td>
</tr>
</table>
now, i need to send this form data using $.post
to my PHP processing page
which looks something like
if($_POST['data']){
$array = json_decode($_POST['data']);
}
so i need to get all my form elements and somehow made then into JSON
and this is what i did:
// assume i can get 5030c9261eca0 from my predefined vars...
$my_array = $("#5030c9261eca0").map(function () { return $(this).is("input")?$(this).val():$(this).text(); } );
//now convert
JSON.stringify($my_array);
// the conversion failed with : Uncaught TypeError: Converting circular structure to JSON
this error poped up:
Uncaught TypeError: Converting circular structure to JSON
how do i fix this?
also, if i do regluar HTTP post via HTML forms, i can recieve form data like $_POST['n_name']
in PHP if i have a HTML form element with attribute n_name
, how can i accomplish the same with the above?