How to send an array to jquery ajax?

Here is a snippet of my code:

   $.ajax({
        url: 'ajax/ajax.feedback.php',
        type: 'POST',
        data: 'author=' + author + '&mail=' + mail + '&subject=' + subject + '&text=' + text +
            '&checkbox[1]=' + checkbox[1] + '&checkbox[2]=' + checkbox[2] + '&checkbox[3]=' + checkbox[3] + '&checkbox[4]=' + checkbox[4] + '&checkbox[5]=' + checkbox[5] +
            '&checkbox[6]=' + checkbox[6] + '&checkbox[7]=' + checkbox[7] + '&checkbox[8]=' + checkbox[8] + '&checkbox[9]=' + checkbox[9],
        success: ...

What’s the easiest way to do it? Just send an array? (and how to read it later in php? if there are any features) In Google – it’s not clear – you need to create an object, use json. In practice, nothing works.


Answer 1, authority 100%

http://api.jquery.com/jQuery.post/

there is an example

$.post("test.php", { 'choices[]': ["Jon", "Susan"] });

for your case it should be something like this:

$.post('ajax/ajax.feedback.php',
    {'author':author,'mail':mail,'subject':subject,'text':text,'checkbox[]':checkbox},
    function (html) { success ... 
    });

and even easier, you can do this:

$.post("test.php", $("#testform").serialize());

on the server, the whole thing will be in the $_POST array;
just display it on the print_r($_POST) screen and everything will become clear


Answer 2, authority 33%

Here is an example using JSON:

var author = document.getElementById("author").value;
...
$.ajax({
    url: 'ajax/ajax.feedback.php',
    type: 'POST',
    data: ({author:author, id:id, mail:mail}),
    success: function(data) {}    
});

data is received via the $_POST array


Answer 3, authority 33%

As always, there are options:
1. Glue everything into a string with a separator (in the string, change all occurrences of the separator to html equivalents) and send everything as one parameter. And on the server, do explode(); .
2. Read here – http://www.simplecoding .org/otpravka-dannyx-v-formate-json-s-pomoshhyu-javascript-i-jquery.html. It seems like everything is written in an accessible way.
In principle, the methods are similar.