建立檔案:jQuery_FormTest.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$( ".send" ).click(function() {
$.post("jquery_PostAndGet.php",
{
Cols1: $('#Cols1').val(),
Cols2: $('#Cols2').val(),
Cols3: 'Cols3'
},
function(data,status){
if(status=='success'){
$("#ShowResult").html(data);
}
});
});
});
</script>
</head>
<body>
<input name="sendByGet" id="sendByGet" class="send" type="button" value="發送 GET 請求"><BR>
<input name="sendByPost" id="sendByPost" class="send" type="button" value="發送 POST 請求"><BR>
<input name="Cols1" id="Cols1" type="text"/><BR>
<input name="Cols2" id="Cols2" type="text"/><BR>
<div id="ShowResult" name="ShowResult"></div>
</body>
</html>
建立檔案:jquery_PostAndGet.php
<?php
if($_POST){
echo "<pre>".print_r($_POST,1)."</pre>";
}
if($_GET){
echo "<pre>".print_r($_GET,1)."</pre>";
}
?>
沒有留言:
張貼留言