Sending serial data with Ajax

Hello,
Contains 2 variable arrays here
How can I include this series?

 $_POST['grup_kim']
 $_POST['emailler']
[grup_kim] => Array
        (
            [0] => 1
            [1] => 2
        )
    [emailler] => Array
        (
            [0] => emailadress.com
            [1] => emailadress.com
            [2] => emailadress.com
            [3] => emailadress.com
        )

    { "grup_kim" : "<?php echo $grup_kim; ?>", "dosyaekle" : "<?php echo $dosyaekle; ?>", "uyeler" : "<?php echo $uyeler; ?>", "emailler" : "<?php echo $emailler; ?>" }

Are you just trying to print valid json?

I don’t know exactly what json means,
I want to send form data from aa.php page to bb.php with ajax
Two of these data are arrays, others are normal singular

I did this temporarily
in aa.php
$grup_kim = implode(", ", $_POST['grup_kim']);

in bb.php
$grup_kim = array_map('trim', explode(',',$_POST['grup_kim']));

This is of course very inexperienced

So, what is that stuff? And maybe I can show a clean way to do what you want.

This example print_ () output

This post, 1 and 2
$_POST[‘grup_kim’]

This post, contains mail addresses
$_POST[‘emailler’]

And you want to merge them and send them to another script?

I’m posting these and others in a form with submit

<form>
checkbox
checkbox
.......
input text
input tex
........
submit
</form>

and I’m sending it to another page with ajax

So using JQuery, you would do something like this on that page:

        let data = $(this).closest('form').serialize();
    $.post('/api/user', data, function (data, status) {
        console.log('Status:' + status + "\nData: " + data);
        //obj = JSON.parse(data);
        alert(data)
    })
        .fail(function (data) {
            let obj = JSON.parse(data.responseText);
            alert(obj.message);
        })
});

Sending all of this form to serialize

Thank you for your help
I write the result that I will try to try

Sponsor our Newsletter | Privacy Policy | Terms of Service