使用 AJAX 向自身 POST PHP 不返回预期值?
参数已成功发送到 POST,基于 Firebugs 控制台,但它不会将结果显示到同一页面。
如何解决这个问题?
劳动.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(){
}
});
});
});