<form id="attack_poll">
Attack 1:<input type="radio" id="attack_select" name="attack_select" value="10" /><br>
Attack 2:<input type="radio" id="attack_select" name="attack_select" value="20" /><br>
Attack 3:<input type="radio" id="attack_select" name="attack_select" value="30" /><br>
<input type="submit" id="submit" value="Submit" />
</form>
<div id="result"> </div>
<script type="text/javascript">
$("#submit").click(function(){
$.ajax( {
type: "POST",
url: "battlephp.php",
data: $('#attack_poll'),
success: function(data)
{
$('#result').html(data)
}
});
});
</script>
我没有收到回复?我在ajax中遗漏了什么?
而且我也使用POST方法..但仍然可以在url中看到参数或值:
http://localhost/battlehtml.php?attack_select=20
PHP代码:
$attack = $_POST['attack_select'];
echo $attack;