【发布时间】:2015-07-29 00:48:28
【问题描述】:
所以我有一个有效的 zurb-foundation 模式,我还有一个 ajax 代码,它每 x 秒刷新一次 div。这是代码
index.php
<a class="th [radius]" href="view-comments.php?ilid=<?= $img['img_id']; ?>" data-reveal-id="viewCommentModal" data-reveal-ajax="true">View</a>
查看-cmets.php
<script>
$(document).ready(function(e) {
setInterval(function() {
$('#load-comments').load('load-comments.php');
}, 3000)
});
</script>
<body>
<div id="load-comments"></div>
</body>
<a class="close-reveal-modal">×</a>
</html>
加载-cmets.php
<?php
require 'dbc.php';
$stmt = $dbc->prepare("SELECT * FROM tbl_comments WHERE img_id=:imageid ORDER by c_id DESC");
$stmt->bindValue(':imageid', $_GET['ilid']);
$stmt->execute();
foreach ($stmt as $data) {
extract($data);
echo "<b>{$c_message}</b>";
}
?>
我的问题是每次加载 load-cmets.php 时,都会显示错误Undefined index: ilid in D:\wamp\www\instalike\load-comments.php on line 4。我该如何解决这个问题?谢谢!
【问题讨论】:
-
是否启用了短标签?如果没有,请尝试将
<?=更改为<?php echo -
是的,它已启用。我知道问题是加载的数据不知道从哪里获取 ilid 的值