I have some values selected by checkboxes that I would like to send to be processed in another PHP script.
When I send the post via ajax to a page that receives the variable $ _POST and prints it, I only see "Array (0) {}".
var objeto = {flag: "exportar"};
var arr = [];
var seletores = document.querySelectorAll(".meusCheckBoxes");
for(i = 0; i < seletores.length; i++){
if(seletores[i].checked){
arr.push(seletores[i]);
}
}
objeto['dados'] = arr;
$.ajax({
url: "Url",
data: objeto,
type: "POST",
contentType: false,
processData: false,
success: function(retorno){
$(".conteudo").html(retorno); //array(0) { }
console.log(objeto); //Object {flag: "exportar", dados: Array[5]}
}
});
I think the problem is that I send an Object with an array inside, because when I send it separately I can see the return.
I need to send an Object because the index ("export", in this case) has to be associative, something the array in javascript does not have.
Note: Note that in "success" the console prints Object with the array correctly posted.