I have a button with the id #filter
<input type="button" name="filter" id="filter" value="Filter" class="btn btn-info" />
My Ajax script is as followed:
<script>
$(document).ready(function(){
$('#filter').click(function(){
var rangestart = $('#rangestart').val();
var rangeend = $('#rangeend').val();
if(rangestart != '' && rangeend != '')
{
$.ajax({
method:"POST",
data:{rangestart:rangestart, rangeend:rangeend},
success:function(data)
{
window.location = 'http://www.test/daterange/dates.php?rangestart=' + rangestart +'&rangeend=' + rangeend
}
});
}
else
{
alert("Please Select Date");
}
});
});
I click my #filter
button, and it works as expected.
rangestart
is passing the value of my input box (in the case below 04-15-2017
)
rangeend
is passing the value of my input box (in the case below 04-20-2017
)
So the page reloads, and the url in the address bar is:
http://www.example.com/daterange/dates.php?rangestart=04-15-2017&rangeend=04-20-2017
In my dates.php
file I have
$rangestart = $_POST['rangestart'];
$rangeend = $_POST['rangeend'];
at the top of the page. But even with the data passing in the address bar $rangestart
and $rangeend
are both empty and thusly cannot do anything with them as intended.
Anyone know what the issue may be?