Answer the question
In order to leave comments, you need to log in
How to send radio value by ajax?
Good afternoon, I can not figure out how to send the radio value by ajax
<input id="radio" type="radio" name="radio" value="1" /> Первое
<input id="radio" type="radio" name="radio" value="2" /> Второе
<div id="aaa"></div>
$(document).ready(function ()
{
$('#radio').on('change', function ()
{
var selectedValue = $('#radio').val();
$.ajax
({
url: "forms.php",
type: 'POST',
data: 'espace_id=' + selectedValue,
success: function(data)
{
$('#aaa').html(selectedValue);
}
});
});
});
<?php
var_dump($_POST['espace_id']);
exit;
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question