I am trying to pass the user's checked HTML radio button value to a PHP variable using Jquery/Javascript and Ajax.
The following is a simplified version of the HTML/Javascript (without error checking, etc.)
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
</head>
<body>
<input type="radio" name="bus_plan" id="smallBtn" value="1"/>
<input type="radio" name="bus_plan" id="smallBtn" value="2"/>
<script type="text/javascript">
$(document).ready(function()
{
$("input[name=bus_plan]").on('change', function(){
var $postID = $('input:radio[name=bus_plan]:checked').val();
$postID = "="+$postID;
});
$.ajax ({
type: "GET",
url: "localhost/ajax/product-group.php",
data: {"postID" : $postID }
});
});
</script>
</body>
</html>
The following is a simplified version of the PHP program (localhost/ajax/product-group.php):
<?php
$postid = $_GET['postID'];
echo "The PostID is ".$postid;
?>
This is running on a MAMP stack.
The Javascript works up until the $.ajax call and then PHP program (localhost/ajax/product-group.php) is never "called".
Any advice or help would be most appreciated.
Thank you.