如果content.php
我没有用数据填充表,那么我可以看到格式正确的 jquery 数据表。但是,如果我用数据填充它(我尝试了数据库数据和一些随机数的手动输入),它不再被格式化并且看起来像地狱。$.get(..)
在这个例子中, (用于)是否会发生test.php
无法正常工作的情况?
测试.php
$(document).ready(function() {
loadContent();
});
function loadContent() {
$.get('modules/mod_scheduler/content.php', function(data) {
$('#table').html(data);
});
}
<div id="table"></div>
内容.php
<?php
include_once '../../include/connect_db.php';
$query = "SELECT * FROM `TestTable`";
$result=execute_query($query);
?>
<table id="newspaper-b" border="0" cellspacing="2" cellpadding="2" width = "100%">
<thead>
<tr>
<th scope="col">Flight Num</th>
<th scope="col">Appearance Time</th>
<th scope="col">Target Time</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php while($row=mysql_fetch_assoc($result)) {
$flightNum=$row['flightNum'];
$appearanceTime=$row['appearanceTime'];
$targetTime=$row['targetTime'];
?>
<tr>
<td><?php echo $flightNum; ?></td>
<td>
<?php echo $appearanceTime;?>
</td>
<td>
<?php echo $targetTime;?>
</td>
<td id="<?php echo $flightNum; ?>">
<div>
<img src='modules/images/edit.png' alt='Edit' />
</div>
</td>
</tr>
<?php }?>
</tbody>
</table>
当然,我还定义了以下内容:
<link type="text/css" rel="stylesheet" href="modules/mod_scheduler/css/demo_table.css"/>
<link type="text/css" rel="stylesheet" href="modules/mod_scheduler/css/demo_page.css"/>
<link type="text/css" rel="stylesheet" href="modules/mod_scheduler/css/demo_table_jui.css"/>
<script type="text/javascript" src="modules/mod_scheduler/js/dataTable/jquery-ui.js"></script>
<script type="text/javascript" src="modules/mod_scheduler/js/dataTable/jquery.dataTables.js"></script>
<script language="javascript" type="text/javascript" src="modules/mod_scheduler/js/jqplot/plugins/jqplot.pointLabels.js"></script>