Here is my code:
$(document).on('click', '#csv_export', function () {
// I need to pass this array to where the form below submits
var arr = ['item1', 'item2'];
$('<form action="csv_export/person?filename=export.csv" method="POST"/>')
.append($('{!! csrf_field() !!}<input type="hidden" name="type" value="save">'))
.appendTo($(document.body)) //it has to be added somewhere into the <body>
.submit();
});
As I've commented in my code, there is arr
that I need to pass it to that page the form points out. How can I do that?
Noted that I can putting this in the form:
<input type="hidden" name="arr" value="'+arr+'">
But I it has two problems:
- character length limitation
- the result will be a string. (while I need an array in the server side)