hi, aku coba nampilin value dari radio option dengan ajax tp yang keluar kenapa option bagian pertama terus yah. bahkan tanpa dicentang pun tetap keluar value option yg pertama. kenapa bisa begitu yah?
<?php
if (isset($_POST['gender'])) {
echo $_POST['gender']; exit;
}
?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$("#klik").live('click', function() {
$.ajax({
url: 'http://localhost/test_ajax.php',
type: 'post',
data: 'gender=' + $("#gender").val(),
dataType: 'html',
success: function(result) {
alert(result);
}
});
});
</script>
<Form name ="form1" Method ="Post" ACTION ="">
<Input type = 'Radio' Name ='gender' id="gender" value= 'male'>Male
<Input type = 'Radio' Name ='gender' id="gender" value= 'female'>Female
<P>
</FORM
<button type="button" id="klik">KLIK</button>
pelajar beginner ajax. tx