I have the following problem, I need to save the values of a checkbox group and send them as array by AJAX to php, so far 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" />create</a>
</form>
<script type="text/javascript">
$(document).ready(function() {
$('#send').click(function() {
$.ajax({
type: "POST",
dataType: 'json',
data: {
'ids': JSON.stringify($('[name="page[]"]').serializeArray())
},
url: "<?php echo site_url();?>/rols/pages",
success : function(data) {
}
});
});
});
</script>
I need to saver how to process that array in my php model, I'm using codeigniter, and I need to walk through each of the values obtained from my ajax, and be able to save them in my database.
Please any input would be greatly appreciated