need your help for this ... My homepage have 3 divs, #Header, #Content, #Footer. All the other pages are being opened inside the #Content div. In one of those pages I have a form with two select lists and one submit button. Just want to click the button and then return another page into the #Content div, showing the values that I select before. Like this:
The origin is: 1
The destiny is: 1
But this code returns the following ...
Notice: Undefined variable: origin in ...
Notice: Undefined variable: destiny in ...
Note: This is working if I don't open the page inside the #Content div
my Html:
<form id="myform" name="myform" action="values.php" method="POST">
<select id="origin" name="origin">
<option value="0" selected>-- Select Origin --</option>
<option value="1">Portugal</option></select>
<select id="destiny" name="destiny">
<option value="0" selected>-- Select Destiny --</option>
<option value="1">Lisboa</option></select>
<input id="btSubmit" name="btSubmit" type="submit" value="search!">
</form>
my Function:
$(document).ready(function(){
$('#btSubmit').click(function(e) {
e.preventDefault();
var url = $('#myform').attr('action');
var method = $('#myform').attr('method');
$.ajax({
type: method,
url: url,
data: $('#myform').serialize(),
success: $('#content').load(url)
});
});
});
my values.php page:
<?php
if(isset($_POST['origin']) || isset($_POST['destiny']))
{
$origin = $_POST['origin'];
$destiny = $_POST['destiny'];
}
echo 'The origin is:' . $origin . '<br>';
echo 'The destiny is:' . $destiny;
?>