I want to send an array to PHP through Ajax.
array = $('.def-mask :checkbox:checked').serialize();
$.ajax({
url: 'ajax/battle.php',
type: 'post',
data: { playerReady: 1, attack: attack, defence: array },
success: function(data) {
alert(data);
}
});
But when I do var_dump($_POST['defence']), I get string(), and not array().
Why do I get a string, and not an array?
[]to the name of your checkboxes? I don't know if jQuery deals with that automatically, I think it does...console.log(decodeURIComponent($.param({ playerReady: 1, attack: attack, defence: array }));and see how your data gets actually formatted.json_decodewouldn't help because the data is not formatted as JSON.var_dumpof$_POST?