kamal kamal - 8 months ago 39
Javascript Question

How to pass js array with post request on form submit to controller in Laravel?

I have multiple js arrays which need to pass to controller on form submit. Is it possible to pass these arrays to controller with post request without using AJAX?


On submit you could convert these arrays to JSON and store this in a hidden input field.

var myJsonString = JSON.stringify(yourArray);

In PHP convert the JSON string to PHP array with json_decode()