I want to pass array in javascript in php. but I only received an html, not an actual array when I put an html in my array.
This is what it look like in Javascript console before passing it on my php.
this is my code on my form, I just put it on my name="options"
<form ...>
<input type="hidden" name="options" value="">
</form>
<script type="text/javascript">
...
$("form").submit(function(e) {
// e.preventDefault();
var options = $('.options li').map(function(){
return $(this).text();
}).get();
// console.log(options);
$(this).find("input[name=options]").val(options);
});
...
</script>
on my Laravel
public function store(Request $request)
{
return $request->options;
}
and when I receive on my PHP Laravel post it form into html, this is what I received. not an array.