I'm trying to store td value in array for passing it in POST method for another page. I got this result, but when I pass to my controller to render the view, when I retrieve this array, the words are splitting.
var arrayObj = [];
$("table tbody tr input:checkbox:checked").each(function(){
$(this).parents("tr").find("td").each(function(){
var text = $(this).text();
arrayObj.push(text);
});
});
HTML:
<table class="table table-responsive" id="osTable" width="100%" cellspacing="0" align="center">
<thead align="center">
<tr>
<th>#</th>
<th>Id OS</th>
<th>Name</th>
</tr>
</thead>
<tbody>
{%for os in ord%}
<tr>
<td><input type="checkbox" name="{{os[0]}}"></td>
<td>{{os[0]}}</td>
<td>{{os[1]}}</td>
{%endfor%}
</tbody>
</table>
Console log:
(3) ["", "66626", "ROMEU"]
0: ""
1: "66626"
2: "ROMEU"
Passing to controller and catching in the other side, when I print this array,
6 6 6 2 6 R O M E U
Using Flask in the nutshel:
if request.method == "POST":
data = request.form['arrayObj']
return render_template('anotherpage.html',datas=data);
I'm using this function to send to another page JavaScript post request like a form submit
var url = "{{url_for('ordemservico.bloco')}}";
post_to_url(url,{'data':arrayObj}, "post");