如何在加载页面的所有其他内容后加载php页面

问题描述 投票:0回答:2

我正在开发一个基于Web的视频频道,我必须添加邮件功能。我添加了一个邮件按钮,所有功能都运行正常,但加载页面需要更多时间。我在mail.php页面中包含了video.php。整页等到包括mail.php。因此需要更多时间。

注意我的应用程序是用PHP codeigniter开发的。 mail.php包含一些js文件,ajax调用和html表单。

我可以先做一些事情来加载所有的页面内容,然后在后台加载mail.php。

在这里我尝试了...

video.php

<script>jQuery("#mail_btn").click(function()jQuery("#div1").load(mail.php);});</script>
<div id="div1" class ="mail_form">
//include_once(mail.php); //it was working fine but it takes time,i want to load mail form here.
</div>

请帮助我或建议任何替代方式。谢谢..

javascript php jquery html codeigniter
2个回答
1
投票

我会添加jQuery延迟加载插件http://jquery.eisbehr.de/lazy/。我在下面添加了一个片段,但插件网站上有更好的示例。

$(function() {
    $("div[data-src]").Lazy();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.1/jquery.lazy.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.lazy/1.7.1/plugins/jquery.lazy.ajax.min.js"></script>

<div data-loader="ajax" data-src="ajax.html">
  <p>Content you want to load later goes here.</p>
</div>

0
投票

我认为你可以使用Ob_startob_end_flush那些功能来控制页面输出加载和显示检查手册在这里php manual

© www.soinside.com 2019 - 2024. All rights reserved.