109
<!DOCTYPE html>
<html>
<head>
<title>Radio button with Ajax and Parse</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<form>
<input type="radio" name="choice" value="1" id="choiceA"> Peace
<input type="radio" name="choice" value="2" id="choiceB"> Joy
<input type="radio" name="choice" value="3" id="choiceC"> Hope
</form>
<div id="result"></div>
<script type="text/javascript">
$(document).ready(function(){
$('input[type=radio]').on('change', function(){
var choice = $(this).val();
// Sending value to Ajax
$.ajax({
type: "POST",
url: "ajax.php",
data: { choice: choice },
success: function(data) {
// Getting response from Parse Script
$('#result').html(data);
}
});
});
});
</script>
</body>
</html>