I am using this jquery code to send value from a dropdown select box to a php script.
This is my jquery code :
$('#filter-value').change(function(){
var filterValue = $(this).val();
//console.log(filterValue);
$.ajax({
type: 'post',
url: 'table.php',
dataType: 'html',
data: {filter: filterValue},
success:function(data){
alert(data);
},
error:function (xhr, ajaxOptions, thrownError){
//On error, we alert user
alert(thrownError);
},
complete: function(){
//alert('update success');
}
});
});
This is my HTML code for dropdown
<form method="post" action="">
<select id="filter-value" name="filter">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
</form>
Now I need to make a mysql query in my table.php
page with value from dropdown and after making the query I want to get date to main page again.
But in my php page I tried something to check is there the value come from dropdown but still I couldn't get it to echo.
This is php :
if ( isset($_POST['filter'])) {
$filter = $_POST['filter'];
echo $filter;
}
Cay you please tell me how can I do this?
Thank you.