I have looked for 2 days to find out how to send a variable with jquery to php. I have searched for over 100 posts on stackoverflow, i tried multiple examples. But i just get it done. So i really hope someone over here would be kind enough to help me find out what i am doing wrong....
<?php
print_r(json_decode($_POST['country']));
?>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('#country').change(function() {
var country = $('#country').val();
$.ajax({
type: 'POST',
data: country,
dataType: 'json',
url: 'timezone/timezone.php',
})
alert("Country: " + country);
});
});
</script>
</head>
<body>
<form method = "post" name="form1">
<select name="country" class="country" id="country">
<option value="NL">Nederland</option>
<option value="BE">Belgie</option>
</select>
</form>
</body>
</html>