[英]how to load php page after loading all the other content of page
I am developing an web based video channel where I have to add mailing functionality. 我正在开发一个基于Web的视频频道,我必须在其中添加邮件功能。 I have added a mail button, all the functionality is working fine, but it is taking more time to load the page. 我添加了一个邮件按钮,所有功能均正常运行,但加载页面需要花费更多时间。 I have included mail.php
in the video.php
page. 我已经包括mail.php
在video.php
页。 Whole page wait until mail.php
is included. 整页等待,直到包括mail.php
。 Hence it is taking more time. 因此,这需要更多时间。
Note my application is developed in PHP codeigniter. 请注意,我的应用程序是用PHP codeigniter开发的。 mail.php contain some js file,ajax call,and html form. mail.php包含一些js文件,ajax调用和html表单。
Can i do something to load all the page content first then at last load mail.php in background. 我可以做些什么来首先加载所有页面内容,然后最后在后台加载mail.php。
here what i tried... 这是我尝试过的...
video.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>
please help me or suggest any alternative way. 请帮助我或提出其他替代方法。 Thanks.. 谢谢..
I would add the jQuery lazy load plugin http://jquery.eisbehr.de/lazy/ . 我将添加jQuery延迟加载插件http://jquery.eisbehr.de/lazy/ 。 I added a snippet below but there are better examples on the plugin site. 我在下面添加了一个代码段,但插件站点上有更好的示例。
$(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>
我认为您可以使用Ob_start
和ob_end_flush
这些功能来控制页面输出加载和显示,请在此处查看手册
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.