
我要提交留言,然后一提交,就能把新留言显示在当前页面,求这个效果的php代码
1个回答
展开全部
list.php
<?php
echo $_POST['content'], $_POST['user'];
index.php
<html>
<head>
<script type="text/javascript" src="jquery.js"></scrpit>
<script type="text/javascript">
$(function() {
$('#pform').submit(function() {
var content = $(this).find('input[name="content"]:first').val();
var user = $(this).find('input[name="user"]:first').val();
var postUrl = $(this).attr('action');
$.ajax({
url:
type: 'post',
data: {'content': content, 'user': user},
success: function(res) {
$('#list').html(res);
}
});
return false;
});
});
</script>
</head>
<body>
<div id="list"></div>
<form method="post" action="list.php" id="pform">
<input name="content" value="哈喽" />
<input name="user" value="isgossip" />
<input type="submit" value="post" />
</form>
....
<?php
echo $_POST['content'], $_POST['user'];
index.php
<html>
<head>
<script type="text/javascript" src="jquery.js"></scrpit>
<script type="text/javascript">
$(function() {
$('#pform').submit(function() {
var content = $(this).find('input[name="content"]:first').val();
var user = $(this).find('input[name="user"]:first').val();
var postUrl = $(this).attr('action');
$.ajax({
url:
type: 'post',
data: {'content': content, 'user': user},
success: function(res) {
$('#list').html(res);
}
});
return false;
});
});
</script>
</head>
<body>
<div id="list"></div>
<form method="post" action="list.php" id="pform">
<input name="content" value="哈喽" />
<input name="user" value="isgossip" />
<input type="submit" value="post" />
</form>
....
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询