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.

    Have your handler give you some debugging info for the time being?

    <?php
    
    echo "Post is: ".print_r($_POST);
    echo "<br /><br />Get is: ".print_r($_GET);

    And, of course, jQuery is Javascript, so I suppose looking the the "Network" tab/panel in your favorite debugger (mine is Firebug) might be of some assistance. You can drill down the request and see all kinds of info about it, including parameter sent and method they were sent by.....

      Write a Reply...