在我使用 jquery.load() 之后,它不会读取 index.php 上的包含内容,并使 home.php 不可读,这是我的示例代码。但是如果我在 home.php 上手动添加了 sqlcon.php 的内容,它可以工作,我该如何解决这个问题?
索引.php
require 'sqlcon.php';
include 'portal.php';
门户网站.php
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/ajax.js" type="text/javascript"></script>
<div id="nav">
<ul>
<li><a href="modules/menu/home.php" class="nav">Home</a></li>
<li><a href="modules/menu/setup.php" class="nav"> Setup</a></li>
</ul>
</div>
<div id="subnav"></div>
主页.php
$result = mysql_query("SELECT announcement_date,announcement_title,announcement_text FROM sp_announcement") or die(mysql_error());
echo "<table id=\"newspaper-b\">";
echo "<thead>";
echo "<tr>";
echo "<th scope=\"col\">Date</th>";
echo "<th scope=\"col\">Title</th>";
echo "<th scope=\"col\">Announcement</th>";
echo "</tr>";
echo "</thead>";
while($row = mysql_fetch_array( $result )) {
echo "<tr>";
echo '<td>' . $row['announcement_date'] . '</td>';
echo '<td>' . $row['announcement_title'] . '</td>';
echo '<td>' . $row['announcement_text'] . '</td>';
echo "</tr>";
}
echo "</table>";
echo "<br>";
echo "<br>";
ajax.js
$(document).ready(function() {
$('a.nav').click(function() {
var url = $(this).attr('href');
$('#subnav').load(url);
return false;
});
});