kamal kamal - 1 year ago 90
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?

Answer Source

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()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download