我试图每隔一段时间刷新页面上的一些元素。我很清楚,现在在这里一万主题有关,我试图让我的工作,但这里是我需要刷新..AJAX Div使用PHP刷新
这是获取生成的代码加载网页时:
<div id="galleria">
<?php
$a = array();
$dir = '../public/wp-content/uploads/2012/01';
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (preg_match("/\.png$/", $file)) $a[] = $file;
elseif (preg_match("/\.jpg$/", $file)) $a[] = $file;
elseif (preg_match("/\.jpeg$/", $file)) $a[] = $file;
}
closedir($handle);
}
$totalImgs = count($a);
$imgUsed = array();
for ($j = 0; $j < 100; $j++)
{
do
{
$randIndex = mt_rand(0, $totalImgs);
}
while ($imgUsed[$randIndex] === TRUE);
$imgUsed[$randIndex] = TRUE;
echo "<img src='" . $dir . '/' . $a[$randIndex] . "' />";
}
?>
</div>
我想每10秒自动刷新一次,但不能重新加载页面。我已经阅读了Ajax,似乎这是可能的,但我似乎无法让它工作。
这一切都是显示广场div,并加载div中的100个图像。然后,环球免税店脚本接管并很好地显示它。 AJAX会更好地工作还是JQuery?
谢谢你的帮助!
完美!谢谢! – 2012-01-12 18:38:12
因此,与外部资源的链接可以作为更好的答案,因为他能够在不到一分钟的时间内尽快发出吱吱声(因为我正在写一些内容)?预计答案是独立的。甚至没有upvote?有时我想放弃堆栈溢出。 :-D – 2012-01-12 18:49:41