form表单序列化
<script type="text/javascript"> $(function(){ $("#send").click(function(){ $.get("get1.php", $("#form1").serialize() , function (data, textStatus){ $("#resText").html(data); // 把返回的数据添加到页面上 } ); }) }) </script>
php页面实现
<?php header("Content-Type:text/html; charset=utf-8"); echo "<div class=\'comment\'><h6>{$_REQUEST[\'username\']}:</h6><p class=\'para\'>{$_REQUEST[\'content\']}</p></div>"; ?>
HTML 实现
<
form id="form1" action="#"> <p>评论:</p> <p>姓名: <input type="text" name="username" id="username" /></p> <p>内容: <textarea name="content" id="content" rows="2" cols="20"></textarea></p> <p><input type="button" id="send" value="提交"/></p> </form>

 

版权声明:本文为timelesszhuang原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/timelesszhuang/p/3680869.html