Jquery+php+ajax实现表单异步提交,动态添加回复评论
HTML代碼:
---------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> TEST </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
<!--
$(document).ready( function () {
$('#btn').click ( function () {
??? $.ajax({
??? url: 'http://localhost/1.php',
??? type: 'POST',
??? data:'name='+$('#name').val(),
??? dataType: 'html',
??? timeout: 1000,
??? error: function(){
???? alert('Error loading XML document');
??? },
??? success: function(html){
???? $('#text').html(html);
??? }
??? });
});
})
//-->
</script>
</head>
<body>
<div id="text"></div>
<input type="text" id="name" name="name" />
<input type="button" value="DO IT ." id="btn"/>
</body>
</html>
---------------------------------------------------------------------------
1.PHP代碼
---------------------------------------------------------------------------
<?php?
$name = $_POST['name'];
echo "you say : ".$name;
?>
本文轉自黃聰博客園博客,原文鏈接:http://www.cnblogs.com/huangcong/archive/2011/04/08/2009638.html,如需轉載請自行聯(lián)系原作者
超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生總結
以上是生活随笔為你收集整理的Jquery+php+ajax实现表单异步提交,动态添加回复评论的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 骑行服的四大作用
- 下一篇: PHPUnit 3.4.10 在wind