我有一个页面加载了一堆 PHP 块,这需要很多时间。它们最初是隐藏的,直到用户使用 jQuery slideToggle 将它们打开。
有什么方法可以先加载 HTML,然后再加载 PHP?
以下是相关的片段:
<script type="text/javascript">
jQuery(function($){
$('a.toggler').click(function(){
$(this).next().slideToggle('slow');
return false; //ensures no anchor jump
});
});
</script>
...
<div class='gallerysection'>
<a href='#' class='toggler'>Logos & Type</a>
<div class='toggle'><?php $album='1755641';include('VimeoAlbumSimple.php'); ?></div>
<a href='#' class='toggler'>Infographics & UIs</a>
<div class='toggle'><?php $album='1755635';include('VimeoAlbumSimple.php'); ?></div>
</div>
从vimeoinclude('VimeoAlbumSimple.php')
加载一堆图像和链接,每次调用都需要几秒钟的时间来加载。页面上有10多个。
这是VimeoAlbumSimple.php
:
require_once('/home/dzg/zinclabs.com/assets/vimeolib.php');
$vimeo = new phpVimeo('807d405c3bf97d7c20060dabce349b6a', '9cc9d85a3b91b1a7');
$vimeo->setToken('274e2c915371a405ac1ec1cd7c3a72a5','3fe84c74bd6b4a9f736a41cb5709a76ec222686c');
$result = $vimeo->call('vimeo.albums.getVideos', array('album_id' => $album,full_response => '1'));
$videos = $result->videos->video;
echo '<div class="gallery">';
foreach ($videos as $video) {echo '
<div class="item">
<a href="http://player.vimeo.com/video/'.$video->id
.'?autoplay=1&title=0&byline=0&portrait=0&wmode=transparent" title="'
.$video->title.'" class="zoombox zgallery1">'
.'<img src="posters/'.$video->id.'.jpg" />'
.'<span class="text">
<span class="title">'.$video->title.'</span>'
.'<span class="duration">'.ltrim(gmdate("i:s", $video->duration),"0").'</span>'
.'<span class="description">'.nl2br($video->description).'</span>'
.'<div class="clear"></div>
</span>
</a>
</div>';
}
echo '</div>';