This question already has an answer here:
I am getting some checkboxes from a php file via AJAX.
$.ajax({
method : "POST",
url : "process.php",
data : dateText,
success : function(result){
$("#slotplace").html(result)
}
});
The contents of process.php is just some checkboxes.
<input type="checkbox" name="M[]" class="days" value="9">9am<br>
<input type="checkbox" name="M[]" class="days" value="10">10am<br>
<input type="checkbox" name="M[]" class="days" value="11">11am<br>
<input type="checkbox" name="M[]" class="days" value="12">12pm<br>
<button class="btn" >alert</button>
Once this is shown, I want to get the values of the selected checkboxes on button click. I am trying this without success, nothing in console either.
$('.btn').on('click',function (){
$("input[type=checkbox]:checked").each(function() {
alert( $(this).val() );
//$('#timeplace').append($(this).val());
});
});
Ideally I want to add the values of the checkboxes to a div #timeplace
but for now I am trying to alert
it but that's not working, any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire