Reputation: 11
I am developing an web based video channel where I have to add mailing functionality. 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. Whole page wait until mail.php
is included. Hence it is taking more time.
Note my application is developed in PHP codeigniter. mail.php contain some js file,ajax call,and html form.
Can i do something to load all the page content first then at last load mail.php in background.
here what i tried...
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..
Upvotes: 1
Views: 1282
Reputation: 2290
I would add the jQuery lazy load plugin 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>
Upvotes: 1
Reputation: 1236
i think you can use Ob_start
and ob_end_flush
those are function to control the page output loading and display
check the manual here
php manual
Upvotes: 0