This basic code below will be used to filter via POST AND jQuery a SELECT
on a PHP page.
The form sends to the same page, jQuery receives and sends to PHP, which receives via $_POST["campanha"];
.
The page should not be giving refresh but this is happening. Can someone help me with this error, please?
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script><scripttype="text/javascript">
$(function(){
$("#bot_enviar").click(function(){
event.preventDefault();
var varCampanha = $("#campanha").val();
$.post('teste.php', {
type:"POST",
campanha: varCampanha
}, function(response){
alert(campanha);
});
});
})
</script>
</head>
<body>
<form action="" method="post" id="bot_enviar">
<select name="campanha" name="campanha">
<option value="1">1</option>
<option value="3">3</option>
</select>
<br>
<input type="submit" >
</form>
Campanha: <?php echo $_POST["campanha"]; ?>
</body>
</html>