hello I have the following problem .. I need to send the values of a group of checkbox in an array, through ajax and process them in php with codeigniter. I am starting with ajax so I do not know much about the matter, its contribution would be very important, I have the following code:
<form id="formid">
<input type="checkbox" value="1" name="page[]" class="up">
<input type="checkbox" value="2" name="page[]" class="up">
<input type="checkbox" value="3" name="page[]" class="up">
<input type="checkbox" value="4" name="page[]" class="up">
<input type="checkbox" value="5" name="page[]" class="up">
<a href="#" id="enviar" />Enviar</a>
</form>
<script type="text/javascript">
$(document).ready(function() {
$('#enviar').click(function(){
var selected = '';
$(":checkbox[name=page]").each(function(){
if (this.checked) {
selected += $(this).val()+', ';
}
});
if (selected != '')
$.ajax({
cache: false,
type: 'post',
data: selected,
url: 'roles/paginas',
success: function(data){
alert('datos enviados');
}
});
else
alert('Debes seleccionar al menos una opción.');
return false;
});
});
</script>
How can I send the values in an array and process them in my controller in php