所以我用AJAX加载我的表数据......这是我的ajax:
function loadSupplies(){
$.ajax({
url : '../controller.php',
data : {loadTable : 1},
success : function(data){
$('#tbodySupplies').html(data);
}
});
}
所以在我的控制器内是这样的:
if(isset($_POST['loadTable'])){
$sql = $init->query("SELECT * FROM supplies");
foreach($sql as $supplies) : ?>
<tr>
<td><?= $supplies->stock_no; ?></td>
<td><?= $supplies->supplies_name; ?></td>
<td><?= ($supplies->quantity <= 5) ? "<span class='text-danger'>" . $supplies->quantity . " in Critical Level</span>" : $supplies->quantity; ?></td>
<td><?= $supplies->unit_of_measure; ?></td>
<td><?= $supplies->type; ?></td>
<td width="10">
<button type="button" class="btn btn-success" onclick="manage(<?= $supplies->id; ?>)">Manage</button>
</td>
</tr>
<?php endforeach; ?>
}
我似乎没有发现错误,但为什么它会给我带来意外的文件结尾&#39;即使我已经把完整的PHP标签。请帮忙。