1
Hello, I’m updating a list with arrays and php, passing two presence parameters(ckeckbox) that returns true or false and id in Hidden, but id does not proceed in the loop getting the first id in the two values:
array(2) { ["id"]=> array(2) { [0]=> string(1) "2" [1]=> string(1) "2" } ["presenca"]=> array(2) { [0]=> string(5) "false" [1]=> string(4) "true" }
$(document).ready(function(){
$('#btn_update').click(function(){
var id = [];
var presenca = [];
$(':checkbox').each(function(i){
presenca[i] = $('#permissao').val();
id[i] = $('#id').val();
if(presenca[i] == this.checked){
this.checked = true;
presenca[i] = this.checked;
}else{
this.checked = false;
presenca[i] =this.checked;
}
});
$.ajax({
url:'<?php echo WEBROOT; ?>/sistema/modulos/processa-permissao.php',
method:'POST',
data:{id:id, presenca:presenca},
success:function()
{
alert('update ok');
}
});
});
The intention is if the user check or not ajax inserts the update in looping.
What am I missing?
tries to pass the variables like 'id[]:id', 'presenca[]:presenca' . and puts the console error
– Julio Henrique
date line did not continue reading, date:{id:id, presenca:presenca},
– Fernando Santana