0
您好,我將如何在下面的代碼中回顯PHP文件中的表單輸入「date」。 (data: "name=Peter&location=Sheffield" + $('input[name="date"]').val(),
)php和ajax傳遞值
此刻我有echo "todays date ".$_POST['date']."<br>";
但它似乎沒有工作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript"
src=http://code.jquery.com/jquery-latest.js>
</script>
<script type="text/javascript">
// This functions starts the ajax to show the output from post.php
function StartAjax(ResultsId){
$.ajax({
type: "POST",
url: "postTest.php",
cache: false,
data: "name=Peter&location=Sheffield" + $('input[name="date"]').val(),
success: function(html, status){
$("#"+ResultsId).append(html);
$('#status').append(status);
}
});
}
</script>
</head>
<body>
<h1> Run Club</h1>
testing
<form>
date: <input type="text" name="date"><br>
</form>
<a href="#" onclick="StartAjax('ResultsId');">Click Here to see updates from postTest.php</a>
<div id="ResultsId"></div>
<div id="status"></div>
</body>
</html>
非常感謝我的朋友 –