I'm using $.ajax to send the values of a form to a PHP script.
The form input fields are read like arrays by PHP, but I don't know how to do the same with javascript and jQuery, and send them in such a way that PHP is able to read them like arrays.
For example a input named foo[bar] in PHP you get it as $_POST['foo']['bar']
Currently I'm sending this data like
data:{
foo_bar: $('form').find('#foo_bar').val(),
foo_xxx: $('form').find('#foo_xx').val()
},
and manually assembling the array in the PHP script.
But it's starting to take a lot of lines of code. Could I somehow automate this, and send all the form input as an multidimensional array to PHP?