<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="./js/jquery.blockUI.js"></script>
<script>
$(document).ready(function(){
$(".menuLink").click(function(){
$('#content').block({
centerY: 0,
css: { top: '40px', left: '', right: '10px' },
message: '<img src="./Images/ajax_loader.gif" /><br /><h3>Loading...Please wait.</h3>'
});
$.ajax({
type: "POST",
url: $(this).attr('href'),
cache: false,
success: function(html){ $("#content").html(html); }
});
});
$(document).ajaxStop(function(){
$('#content').unblock();
});
});
</script>
这是我在单击时获取 div id=menu 中的链接的代码,它们将 php 文件加载到 div id=content ahref 我在这里。
<p><a class="menuLink" href="Test.php" onclick="return false;">Wall</a></p>
现在,当在 div id=menu 上单击该链接时,类和带有上面脚本的 onclick 使 Test.php 加载到 div id=content 中。
下面是 Test.php 中的脚本
session_start();
include_once("connect.php");
include_once("functions.php");
if($_POST['WallSubmit'] && $_POST['Wall']){
$wall = makesafe($_POST['Wall']);
mysql_query("INSERT INTO `Wall` (`ID`, `Username`, `MessageBy`, `Date`, `Message`) VALUES ('', '', '$username', '" . time() . "', '$wall')");
}
<form method='post'>
<table class="default" style="width: 80%" align="center">
<tr>
<td class="subheader">Wall</td>
</tr>
<tr>
<td class="content">Post a comment.<br /><textarea name='Wall' id='Wall' style='width: 99%; height: 110px;'></textarea><br /><br/><center><input type='submit' value='Post' name='WallSubmit' /></center><br /><hr><br />Latest Comments.</td>
</tr>
</td>
</table>
</form>
现在我遇到的问题是,一旦我点击了菜单上的墙,就像在 href 中看到的那样,它加载到 div id=content 完全没有问题,所以现在 Test.php 显示在内容 div 中,但是现在当我填写该表格时Test.php 它只是刷新到默认内容页面,如果它没有刷新到那里的默认内容,它不会更新数据库,然后单击时按钮不会做任何事情,现在我知道编码适用于数据库和表单在框架布局中进行了测试,并且如果我将 Test.php 设置为默认内容页面也可以工作,它将像我在页面中一样放置默认内容。
<div id="content" class="auto">
<?include_once("Test.php");?>
</div>
解决方案是什么?我知道这听起来有点令人困惑,但我只想弄清楚一旦我单击菜单上的 Wall 并将 Test.php 加载到 div id=content 如何在 Test.php 中获取表单来完成它的工作,哈哈。