Send JavaScript Array Through JQuery AJAX POST
What I want to do is send an JavaScript Array to a PHP file. This is what I got: var mydata = [];         console.log(document.getElementsByTagName('input')[0].name);         for (
Solution 1:
Try to use this code and see the changes.
remove the
contentType: 'application/json',
dataType: 'json'
And change var mydata = [] into var mydata = {}
your ajax should look like this
        $.ajax({
            method: "POST",
            url: "q.php",
            data: {'lol': mydata}
        })
        .done(function( msg ) {
            alert( "Data Saved: " + msg );
            $('#debug').html(msg);
        });
You dont have to stringify your mydata because you already decleared it as object.
Hope it helps
Post a Comment for "Send JavaScript Array Through JQuery AJAX POST"