POST PHP to itself using AJAX does not return the expected value?
Parameters has been successfully send to POST, based on Firebugs Console but it does not dispaly the result to the same page.
How to fix this?
labor.php
<?php
if(isset($_POST['from']) && isset($_POST['from']))
{
echo 'from: '.$_POST['from'].
' to: '.$_POST['to'];
//do something here
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Labor Reports</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#datepicker_from" ).datepicker();
$( "#datepicker_to" ).datepicker();
$( "button" )
.button()
.click(function() {
$.ajax({
url: 'labor.php',
type: 'POST',
data: { from: $('#datepicker_from').val().trim(), to: $('#datepicker_to').val().trim() },
success: function(){
}
});
});
});